[Msys2-users] Debugging undeterministic segfaults

David Macek david.macek.0 at gmail.com
Tue Nov 4 12:28:20 UTC 2014


On 4. 11. 2014 13:07, Gintautas Miliauskas wrote:
> But running it just prints "hi", no indications of a crash or anything, regardless of the value of the MSYS variable:

Either the compiler, or C library is too smart for this. I'd guess your compiler is working with undefined behavior optimizations, because with my compiler, I get both "hi" and "bye" (or not, when I pass -Og). Try this code:

#include <stdio.h>
int main() {
  printf("hi\n");
  ((void(*)())(0))();
  printf("bye\n");
  return 0;
}


-- 
David Macek


More information about the ghc-devs mailing list