Comment by 32gbsd
3 years ago
I knew rust had to be mentioned. But this is a optimization bug. I break my code several times while optimizing thinking a minor change wont matter then end up undoing it all.
3 years ago
I knew rust had to be mentioned. But this is a optimization bug. I break my code several times while optimizing thinking a minor change wont matter then end up undoing it all.
It's not a bug. This is perfectly acceptable behaviour according to the language standard. If anything, it's a standard bug.
This is not a bug. This is the model of C. You should blame C not GCC.
I blame GCC. The C standards committee is some out of touch with reality conglomerate working in a vacuum, taking 50 years of language history into account.
I expect my compiler vendor to be on my side, ie produce a compiler that helps me write good software and not get in my way. GCC is doing the opposite, it's deliberately looking to use the standard to fuck me over in the most subtle and unexpected ways. Signed integer overflow is undefined; that gives compiler authors the liberty to make it do anything they want, including well defined things that anyone would expect and find useful. But GCC decides to fuck you over so their devs can give you an arrogant reply and impose their superiority if you show up on their bug tracker.
Turns out people get upset when their code goes slower because the the compiler added traps on signed overflow.
8 replies →
GCC's developers work for companies that want more optimizations. UB is the way you get these optimizations.
But "gcc -fsanitize=undefined" is just as easy to run as "gcc -O3" is.