I can't get clang's c++-analyzer
to work on a toy C++ file.
#include <iostream>
using namespace std;
int main()
{
int t[4];
int x,y;
t[5]=1;
if(x)
y = 5;
x = t[y];
}
makefile is just
all: t.cpp
$(CXX) t.cpp
scan-build make
output:
scan-build: 'clang' executable not found in '/usr/share/clang/scan-build/bin'.
scan-build: Using 'clang' from path: /usr/bin/clang
/usr/share/clang/scan-build/c++-analyzer t.cpp
scan-build: Removing directory '/tmp/scan-build-2012-06-14-6' because it contains no reports.
How to make c++-analyzer work? Clang's version is 2.9 on Ubuntu 11.10.
EDIT: I'm aware the code is incorrect. The point is that Clang does not complain about the obvious bugs. If I paste the above code to a .c file (without the using ...
) clang correctly emits warnings.
Here's the reason:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-September/011194.html
>>> When I run "clang --analyze" on my c++ source files individually I get reports,
>>> but none when using the scan-build tool.
>>
>> This is intended behavior. C++ support is still alpha and so it isn't enabled
>> by default in scan-build. It's really only intended to be used by those
>> currently hacking on the analyzer.
>>
>> If you want to enable C++ analysis, you must define the environment variable
>> CCC_ANALYZER_CPLUSPLUS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With