Incidencia #38911

MinGW results in incorrect compilations of program

Abrir Fecha: 2019-01-30 18:29 Última actualización: 2019-01-31 00:49

Informador:
Propietario:
(Ninguno)
Tipo:
Estado:
Cerrado
Componente:
Hito:
(Ninguno)
Prioridad:
5 - Medium
Gravedad:
5 - Medium
Resolución:
Invalid
Fichero:
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
Comentario

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
  • Resolución Update from Ninguno to Invalid
  • Estado Update from Open to Cerrado
Comentario

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

Editar

Please login to add comment to this ticket » Entrar