[PATCH] D53713: Add extension to always default-initialize nullptr_t.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 14 14:38:43 PST 2018


rsmith added a comment.

I'm concerned that this will hide real bugs by suppressing the bogus warnings in (only) the simple cases. There is no "read a value from memory" operation on type `nullptr_t` (just like for, say, class types), and any warning that believes there is is incorrect. For example, given

  alignas(nullptr_t) char buffer[sizeof(nullptr_t)];
  nullptr_t *p = (nullptr_t*)buffer;
  nullptr_t q = *p;

... there is no uninitialized use, but this patch will do nothing to make static analysis (etc) aware of that.

I think the real problem here is that our AST representation is wrong. We use `CK_LValueToRValue` to model a read from memory, but we also use it in examples like the above where there is no read from memory.



================
Comment at: test/Analysis/nullptr.cpp:136
-    invokeF(p); // expected-warning{{1st function call argument is an uninitialized value}}
-                // expected-note at -1{{1st function call argument is an uninitialized value}}
   if (getSymbol()) // expected-note   {{Assuming the condition is false}}
----------------
This bug is already fixed in trunk.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53713/new/

https://reviews.llvm.org/D53713





More information about the cfe-commits mailing list