[LLVMdev] Is this a bug in clang?

Csaba Raduly rcsaba at gmail.com
Wed Apr 20 02:24:47 PDT 2011


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

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.

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




More information about the llvm-dev mailing list