News for hackers. Stuff that matters.
Re:Both true and false: a Zen moment with C by simias on Wednesday June 27, 2012 @10:53AM (#4167260)
Still, gcc is a pretty serious piece of software (no more starting nethack these days), so while the behaviour is undefined it's still interesting to see why the compiler ended up generating a code that behaves so weirdly.

If you need to find a use for it, it might make it easier to spot an undefined behaviour later and finding its cause ("hey, this evalutates both to true and false, it must be an unitialized bool!").

So it's still interesting and might not be completely pointless.

Re:Both true and false: a Zen moment with C by defrost on Wednesday June 27, 2012 @12:12PM (#4167669)
LLVM is more interesting piece of software, gcc is kind of crusty and warty.

Still, I'm glad you're interested in the language, if you're interested in undefined behaviour then you should carefully and closely read the latest free draft standard (N1570) and perhaps implement a small C compiler of your own ( Appel : Modern Compiler Implementation ).

There are many C compilers, they are free to do whatever they want when behaviour is undefined and in many cases you'll unfortunately not see anything odd at all, not until you port your code, change your flags or upgrade the compiler and then you'll having a seething mass of "well this stuff worked when we tested it" errors.

Strapping yourself into a vehicle and driving off a cliff teaches you a little about the dangers of accidents and gives you a reason to drive safely, it doesn't particularly teach much about the practice of safe driving.

The example code drove off the road, what happened next really isn't all that exciting.

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf

http://www.cs.princeton.edu/~appel/modern/c/

Re:Both true and false: a Zen moment with C by dllthomas on Wednesday June 27, 2012 @04:56PM (#4169222)
Many serious pieces of software are crusty and warty.