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

           Summary: !!(intval==constant) generates assert in APInt
                    assigment
           Product: tools
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P
         Component: analyze
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


I've just got clang's static analyzer up and running on our code base. One of
the problems I've come across that it chokes on asserts we have of the form
'ASSERT( x < 20 )'. After some digging, I have this minimal repro:

int f(int c)
{
        return !!(c==0);
}

Which causes clang --analyze to assert in APInt::operator==:

$ clang --analyze -v main.cpp
clang version 2.0 (trunk 104221)
Target: i386-pc-cygwin
Thread model: posix
 "/usr/local/bin/clang" -cc1 -triple i386-pc-cygwin -analyze -disable-free
-main-file-name main.cpp -analyzer-store=regi
on -analyzer-opt-analyze-nested-blocks -analyzer-check-dead-stores
-analyzer-check-objc-mem -analyzer-eagerly-assume -an
alyzer-check-objc-methodsigs -analyzer-check-objc-unused-ivars -analyzer-output
plist -w -mrelocation-model static -mdis
able-fp-elim -mconstructor-aliases -target-cpu pentium4 -v -resource-dir
/usr/local/lib/clang/2.0 -ferror-limit 19 -fmes
sage-length 120 -fexceptions -fgnu-runtime -fdiagnostics-show-option
-fcolor-diagnostics -o main.plist -x c++ main.cpp
clang -cc1 version 2.0 based upon llvm 2.8svn hosted on i386-pc-cygwin
#include "..." search starts here:
#include <...> search starts here:
 /cygdrive/c/dev/libcxx_svn/include
 /usr/local/lib/clang/2.0/include
 /usr/include
End of search list.
assertion "BitWidth == RHS.BitWidth && "Comparison requires equal bit widths""
failed: file "/cygdrive/c/dev/llvm_svn/in
clude/llvm/ADT/APInt.h", line 819, function: bool llvm::APInt::operator==(const
llvm::APInt&) const
Stack dump:
0.      Program arguments: /usr/local/bin/clang -cc1 -triple i386-pc-cygwin
-analyze -disable-free -main-file-name main.
cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks
-analyzer-check-dead-stores -analyzer-check-objc-mem -ana
lyzer-eagerly-assume -analyzer-check-objc-methodsigs
-analyzer-check-objc-unused-ivars -analyzer-output plist -w -mreloc
ation-model static -mdisable-fp-elim -mconstructor-aliases -target-cpu pentium4
-v -resource-dir /usr/local/lib/clang/2.
0 -ferror-limit 19 -fmessage-length 120 -fexceptions -fgnu-runtime
-fdiagnostics-show-option -fcolor-diagnostics -o main
.plist -x c++ main.cpp
1.      <eof> parser at end of file
2.      main.cpp:3:2: Error evaluating statement
3.      main.cpp:3:2: Error evaluating statement
4.      main.cpp:3:9: Error evaluating statement
5.      main.cpp:3:9: Error evaluating statement
clang: error: analyzer command failed due to signal 6 (use -v to see
invocation)


I'm compiling clang from source on cygwin/Windows 7, but I suspect this is
platform-independent. One thing I did notice was that compiling the same code
as main.c failed to generate an assert. 

Cheers,
Paul

-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to