Ticket #38911

MinGW results in incorrect compilations of program

Open Date: 2019-01-30 18:29 Last Update: 2019-01-31 00:49

Reporter:
Owner:
(None)
Type:
Status:
Closed
Component:
MileStone:
(None)
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Invalid
File:
1
Vote
Score: 0
No votes
0.0% (0/0)
0.0% (0/0)

Details

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
Comment

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
  • Resolution Update from None to Invalid
  • Status Update from Open to Closed
Comment

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

Edit

Please login to add comment to this ticket » Login