User: Password:
|
|
Subscribe / Log in / New account

Distributions looking at LLVM

Distributions looking at LLVM

Posted Mar 22, 2012 19:49 UTC (Thu) by jhhaller (subscriber, #56103)
Parent article: Distributions looking at LLVM

The worst thing a compiler can do is generate incorrect code.

I recently saw a case where clang generated incorrect code when a novice programmer used something like "for(d=0.0; d < 5.0; d++)", and d had the wrong value in the loop. Now, I would never use a double as a loop index, but I would rather see an error than wrong code. If all that is done to validate a compiler is to be sure it compiles things properly, this kind of problem won't be found until someone tries to use the software with incorrect code generation. That's not to say one wouldn't have the same issue moving from one release of gcc to another, just that any change in compilers can have unexpected consequences.


(Log in to post comments)

Distributions looking at LLVM

Posted Mar 22, 2012 21:47 UTC (Thu) by NAR (subscriber, #1313) [Link]

What was the invalid value? 4.999999 instead of 5.0?

Distributions looking at LLVM

Posted Mar 22, 2012 21:53 UTC (Thu) by jhhaller (subscriber, #56103) [Link]

No, it was one less than it should have been, like it waited to do the ++ part of d++ until after the loop iteration rather than before, or used the wrong register inside the loop. ++d worked fine.

Distributions looking at LLVM

Posted Mar 23, 2012 14:48 UTC (Fri) by jezuch (subscriber, #52988) [Link]

Looks like a corner case triggered by code no one would ever write. Did you file a bug report? I would also point out that GCC has tons of bugs like this fixed in every minor release, so it's nothing special (yet).


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds