[LLVMbugs] [Bug 17940] New: Undetected use of uninitialised variable (detected at -O2 -Wall by gcc)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Nov 15 06:10:06 PST 2013


            Bug ID: 17940
           Summary: Undetected use of uninitialised variable (detected at
                    -O2 -Wall by gcc)
           Product: clang
           Version: 3.3
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: christophe at taodyne.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11543
  --> http://llvm.org/bugs/attachment.cgi?id=11543&action=edit
Source code example

At -O2 or above, GCC 4.2 detects that the 'result' variable can be used
uninitialised in the attached code. clang 3.3svn (as shipped with OSX) does

Compile with "true" g++ -O2 -Wall:

g++ -Wall -O2 -c /tmp/glop.cpp                                                  
/tmp/glop.cpp: In function 'char* undetected()':                                
/tmp/glop.cpp:6: warning: 'result' may be used uninitialized in this function 

With llvm-g++, there is no message.

Reduced test case:

extern bool dont_stop();
extern char *data(unsigned);

char *undetected()
    char *result;
    for (unsigned count = 0; count < 2 && dont_stop(); count++)
        result = data(count);
    return result;

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131115/feed150b/attachment.html>

More information about the llvm-bugs mailing list