[cfe-dev] Static Analyzer: NullDereference checker report not visible
Gábor Kozár
kozargabor at gmail.com
Fri Jul 26 06:15:00 PDT 2013
I'm playing around with the NullDereference checker (Dereference.cpp) in an
attempt to understand how it works.
I've discovered a strange phenomenon. Sometimes the checker finds a bug,
calls reportBug(), a BugReport is created and emitted -- but no warning is
raised.
My test code:
struct Foo
{
int bar;
};
Foo* getFooPtr(bool cond)
{
return cond ? new Foo : nullptr;
}
int main(int argc, const char** argv)
{
Foo* fp = getFooPtr(argc % 2 == 1);
if( ! fp )
{
fp->bar = 0; // bug!
}
return 0;
}
Interestingly enough, if I replace the getFooPtr definition above with this:
extern Foo* getFooPtr(bool);
Then the report becomes visible.
Note: I'm using Clang 3.3, but I also checked the latest SVN revision, and
there don't seem to be any changes to the DereferenceChecker code.
Is this a bug, or why could this be? Thanks!
Gabor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130726/dec85df7/attachment.html>
More information about the cfe-dev
mailing list