待辦事項 #38911

MinGW results in incorrect compilations of program

啟用日期: 2019-01-30 18:29 最後更新: 2019-01-31 00:49

回報者:
負責人:
(無)
類型:
狀態:
關閉
元件:
里程碑:
(無)
優先權:
5 - 中
嚴重程度:
5 - 中
處理結果:
Invalid
檔案:
1
Vote
Score: 0
No votes
0.0% (0/0)
0.0% (0/0)

細節

The attached program, when compiled with MinGW, creates an application that on execution gives different results than if the program was compiled by GCC on Linux(i.e. Ubuntu)

Ticket History (3/4 Histories)

2019-01-30 18:29 Updated by: sai_vamsi_adapa
  • New Ticket "MinGW results in incorrect compilations of program" created
2019-01-30 23:10 Updated by: sai_vamsi_adapa
評語

The problem was with the code, not the compiler. In Ubuntu, variables are initialized to 0, whereas in windows MinGW does not do this. This led to the false conclusion that compiler was at fault.

2019-01-31 00:49 Updated by: keith
  • 處理結果 Update from to Invalid
  • 狀態 Update from 開啟 to 關閉
評語

Yep. Failure to initialize the iterator variable, in a for loop, is a user error ... not a compiler bug. Even if Ubuntu's compiler has (apparently) initialized it suitably, in this case, that's not a feature you should rely on ... ever. References to uninitialized variables always induce undefined behaviour, which is always a programming error.

I guess you resolved this by yourself, so I'm closing the ticket.

Attachment File List

  • red.c(1KB)
    • the file containing the code mentioned and the outputs achieved when compiled using different methods

編輯

Please login to add comment to this ticket » 登入