[LLVMdev] Uninitialized variables -- LLVM bug?
Riyaz Puthiyapurayil
Riyaz.Puthiyapurayil at synopsys.com
Fri Aug 16 15:20:55 PDT 2013
Consider the following C code. When it is compiled using clang with ' -O', the assert fires. Gcc seems to do the opposite.
#include <assert.h>
int main()
{
unsigned a; // uninitialized!
unsigned b = a;
assert(b == a); // shouldn't this be always true?
return 0;
}
Would you consider this a LLVM bug? I think GVN is responsible for this. I don't know if it falls within the realm of "undefined" or "implementation specific" behavior but there are probably examples of code where one can "correctly" skip initialization. The Briggs-Torczon sparse set data structure comes to mind (where you are not comparing two uninitialized variables but an uninitialized variable with an initialized variable-LLVM seems to do the right thing in that case, though).
n Riyaz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130816/634f1ba0/attachment.html>
More information about the llvm-dev
mailing list