[PATCH] D51057: [analyzer][UninitializedObjectChecker] Fixed dereferencing

Umann Kristóf via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 7 03:56:26 PDT 2018


Szelethus added inline comments.


================
Comment at: test/Analysis/cxx-uninitialized-object.cpp:879-902
+struct LambdaWrapper {
+  void *func; // no-crash
+  int dontGetFilteredByNonPedanticMode = 0;
+
+  LambdaWrapper(void *ptr) : func(ptr) {} // expected-warning{{1 uninitialized field}}
+};
+
----------------
NoQ wrote:
> Szelethus wrote:
> > I'm 99% sure this is a FP, but it doesn't originate from the checker. Shouldn't `*ptr` be undef after the end of the code block as `lambda`'s lifetime ends?
> > 
> > Nevertheless, it did cause a crash, so here's a quick fix for it.
> I'm pretty sure that all sorts of contents of `lambda` aka `*ptr` are undefined once it goes out of scope. Moreover, `ptr` is now a dangling pointer, and reading from it would cause undefined behavior. I'm not sure if the analyzer actually models this though. 
> 
> But on the other hand, even if it didn't go out of scope, i don't really see where field `a` was initialized here.
> 
> Soo what makes you think it's a false positive?
> Soo what makes you think it's a false positive?

Poor choice of words I guess. Its not a false positive (as the entire region of that lambda is undefined), but rather a false negative, as the analyzer doesn't pick up that `*ptr` is a dangling pointer.


https://reviews.llvm.org/D51057





More information about the cfe-commits mailing list