Open
Description
#include <memory>
void f(size_t n) {
std::unique_ptr<int[]> d(new int[n]{});
if (d.get()[0]) {}
}
[<source>:5:7: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]
5 | if (d.get()[0]) {}
| ^~~~~~~~~~
[<source>:3:28: note: Storing uninitialized value]
3 | std::unique_ptr<int[]> d(new int[n]{});
| ^~~~~~~~~~~~
[<source>:3:26: note: Calling constructor for 'unique_ptr<int[], std::default_delete<int[]>>']
3 | std::unique_ptr<int[]> d(new int[n]{});
| ^~~~~~~~~~~~~~~
https://godbolt.org/z/Khaozjs9G
Originally observed with boost::scoped_array.