On Wed, Apr 20, 2011 at 11:24 AM, Csaba Raduly <rcsaba at gmail.com>
wrote:> On Wed, Apr 20, 2011 at 10:44 AM, Joe Armstrong wrote:
>>
>> It seems very strange to me that the ansi standard says "XXX is
>> undefined" and that both clang and gcc
>> can detect that something is undefined and that by default they
>> compile the offending code without
>> any feelings of guilt.
>
> "The good thing — the only good thing! — about undefined behavior in
> C/C++ is that it simplifies the compiler’s job..."
>
> http://blog.regehr.org/archives/213
Excellent article - thanks
>
> I don't think "clang and gcc can detect that something is
undefined".
> It's more likely that undefined behavior is lumped together with valid
> C code. The machine code generated for valid C code is required to
> behave correctly. Code generated for undefined behavior "works"
on a
> best-effort basis.
I still think that in the cases where clang/gcc can detect undefined behavior
they should absolutely refuse to compile the programs. i + i++ is undefined
value, both clang an gcc compile this without any moral qualms - no warnings -
nothing - complete psychopathic behavior :-)
/joe
> Csaba
> --
> GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
> The Tao of math: The numbers you can count are not the real numbers.
> Life is complex, with real and imaginary parts.
> "Ok, it boots. Which means it must be bug-free and perfect. " --
Linus Torvalds
> "People disagree with me. I just ignore them." -- Linus Torvalds
>