[LLVMbugs] [Bug 12856] New: False positive: Assigned value is garbage or undefined

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed May 16 17:31:51 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12856

             Bug #: 12856
           Summary: False positive: Assigned value is garbage or undefined
           Product: clang
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: wiml at omnigroup.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 8574
  --> http://llvm.org/bugs/attachment.cgi?id=8574
Source file generating spurious warning

The attached snippet produces a warning, "Assigned value is garbage or
undefined", about the assignment "px = points[corner].x".

This happens both with "Apple clang version 3.1 (tags/Apple/clang-318.0.58)
(based on LLVM 3.1svn)" on OSX 10.7, and "Apple clang version 1.7
(tags/Apple/clang-77) (based on LLVM 2.9svn)" on OSX 10.6. I haven't tried ToT.

If that assignment is removed, the warning is given about the assignment to py,
or the expression's use in the function call, or wherever the first index into
points[] is. If 'corner' is assigned a constant value (0,1,2,3) the warning
goes away, but if 'corner' comes from an extern function call the warning
remains.

Example command line:


%
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-x objective-c -arch i386 -fmessage-length=0 -std=gnu99 -Wno-trigraphs
-fpascal-strings -Os -Werror -Wno-missing-field-initializers
-Wmissing-prototypes -Wreturn-type -Wno-implicit-atomic-properties -Wformat
-Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wunused-label
-Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-uninitialized
-Wunknown-pragmas -Wno-shadow -Wno-four-char-constants -Wsign-compare
-Wshorten-64-to-32 -Wpointer-sign -Wnewline-eof -Wno-selector
-Wno-strict-selector-match -Wno-undeclared-selector
-Wno-deprecated-implementations -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
-fasm-blocks -Wprotocol -Wdeprecated-declarations -mmacosx-version-min=10.6 -g
-Xclang -analyzer-disable-checker -Xclang deadcode.IdempotentOperations -Xclang
-analyzer-checker -Xclang osx.cocoa.experimental.SelfInit  -Wall   --analyze
SpuriousWarning.m -o foom
SpuriousWarning.m:25:5: warning: Assigned value is garbage or undefined
    float px = points[corner].x;
    ^          ~~~~~~~~~~~~~~~~
1 warning generated.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list