チケット #38911

MinGW results in incorrect compilations of program

登録: 2019-01-30 18:29 最終更新: 2019-01-31 00:49

報告者:
担当者:
(未割り当て)
チケットの種類:
状況:
完了
コンポーネント:
マイルストーン:
(未割り当て)
優先度:
5 - 中
重要度:
5 - 中
解決法:
不正
ファイル:
1
投票
点数: 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)

チケットの履歴 (4 件中 3 件表示)

2019-01-30 18:29 更新者: sai_vamsi_adapa
  • 新しいチケット "MinGW results in incorrect compilations of program" が作成されました
2019-01-30 23:10 更新者: 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 更新者: keith
  • 解決法なし から 不正 に更新されました
  • 状況オープン から 完了 に更新されました
コメント

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.

添付ファイルリスト

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

編集

このチケットにコメントを追加するには、ログインが必要です » ログインする