Open Quuxplusone opened 10 years ago
Attached static_checker_bug.zip
(4454 bytes, application/zip): Trivial source code and .pro file that reproduce the problem
Actually this bug is easier to reproduce than I thought; in particular it does
not require Qt.
Simplified steps to reproduce:
1) Create a file "Makefile" with these contents:
CXXFLAGS += -std=c++11 -stdlib=libc++
test: test.o
$(CXX) $(LFLAGS) -o $@ $^ $(LIBS)
clean:
rm *.o
2) Create a file "test.cpp" with these contents:
#include <string>
int main(int, char **)
{
return 0;
}
3) Run "scan-build make" using checker-276.
4) Note these erroneous results:
jeremy-friesners-mac-pro-3:crap jaf$ scan-build make
scan-build: Using '/Users/jaf/checker-276/bin/clang' for static analysis
/Users/jaf/checker-276/libexec/c++-analyzer -std=c++11 -stdlib=libc++ -c -o
test.o test.cpp
test.cpp:1:10: fatal error: 'string' file not found
#include <string>
^
1 error generated.
test.cpp:1:10: fatal error: 'string' file not found
#include <string>
^
1 error generated.
/Users/jaf/checker-276/libexec/c++-analyzer -o test test.o
scan-build: 0 bugs found.
scan-build: The analyzer encountered problems on some source files.
scan-build: Preprocessed versions of these sources were deposited in
'/var/folders/xb/6c5bw1tx4qx8qkhd8rk98yc00000gn/T/scan-build-2014-07-21-112651-9974-1/failures'.
scan-build: Please consider submitting a bug report using these files:
scan-build: http://clang-analyzer.llvm.org/filing_bugs.html
jeremy-friesners-mac-pro-3:crap jaf$
This seems like a problem with the clang version bundled with the checker. I encounter the same problem with XCode 6.1.1 using xcodebuild as the build tool. That is, everything builds fine with just xcodebuild but fails to find even standard library includes when run with scan-build from checker-276.
However, using a different clang with this checker works, i.e. by passing: --use-analyzer Xcode
Hi Jake,
I tried the flags you suggested, but still got errors, albeit different ones
(using the same Makefile and test.cpp as above):
Jeremys-Mac-mini:crap lcsuser1$ scan-build --use-analyzer Xcode make
scan-build: Using
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang'
for static analysis
/Users/lcsuser1/checker-276/libexec/c++-analyzer -c -o test.o test.cpp
In file included from test.cpp:1:
In file included from
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:435:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:90:10:
fatal error: 'wchar.h' file not found
#include <wchar.h> // for mbstate_t
^
1 error generated.
In file included from test.cpp:1:
In file included from
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:435:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:90:10:
fatal error: 'wchar.h' file not found
#include <wchar.h> // for mbstate_t
^
1 error generated.
/Users/lcsuser1/checker-276/libexec/c++-analyzer -o test test.o
scan-build: 0 bugs found.
scan-build: The analyzer encountered problems on some source files.
scan-build: Preprocessed versions of these sources were deposited in
'/var/folders/v7/4z87j4sx21d00s8cptxsc0xr0000gp/T/scan-build-2015-07-28-084408-15047-1/failures'.
scan-build: Please consider submitting a bug report using these files:
scan-build: http://clang-analyzer.llvm.org/filing_bugs.html
Jeremys-Mac-mini:crap lcsuser1$
I did find a work-around that works for me, though... if I add this line to my
Makefile:
CXXFLAGS += -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/
-I/Users/lcsuser1/checker-276/lib/c++/v1
... then I don't get any errors:
Jeremys-Mac-mini:crap lcsuser1$ scan-build make
scan-build: Using '/Users/lcsuser1/checker-276/bin/clang' for static analysis
/Users/lcsuser1/checker-276/libexec/c++-analyzer -std=c++11 -stdlib=libc++ -
isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/
-I/Users/lcsuser1/checker-276/lib/c++/v1 -c -o test.o test.cpp
/Users/lcsuser1/checker-276/libexec/c++-analyzer -o test test.o
scan-build: Removing directory
'/var/folders/v7/4z87j4sx21d00s8cptxsc0xr0000gp/T/scan-build-2015-07-28-084954-
15274-1' because it contains no reports.
scan-build: No bugs found.
Come accros same problem with you. Pls try --use-analyser /usr/bin/g++.
Hi Quark,
I tried your suggestion and I can confirm that running the command line "scan-build --use-analyzer /usr/bin/g++ make" avoids the problem. Thank you for the suggestion! :)
Jeremy
static_checker_bug.zip
(4454 bytes, application/zip)