RedDocMD marked an inline comment as done. RedDocMD added inline comments.
================ Comment at: clang/test/Analysis/smart-ptr-text-output.cpp:339 +void makeUniqueForOverwriteReturnsNullUniquePtr() { + auto P = std::make_unique_for_overwrite<A>(); // expected-note {{std::unique_ptr 'P' constructed by std::make_unique_for_overwrite is null}} + *P; // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}} ---------------- NoQ wrote: > Mmm wait a sec, that doesn't look like what the spec says. > > https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique: > > Same as (1), except that the object is default-initialized. This overload > > participates in overload resolution only if T is not an array type. The > > function is equivalent to `unique_ptr<T>(new T)` > > It zero-initializes the //pointee//, not the //pointer//. > > The difference between `std::make_unique<A>()` and > `std::make_unique_for_overwrite<A>()` is the difference between > value-initialization (invoking the default constructor) and > zero-initialization (simply filling the buffer with `0`s). Oops! Look like I completely misunderstood the spec. So basically, the inner pointer is //not// null, and we have the same assumptions that apply for `std::make_unique`. Only problem is that, for primitive types, the value obtained on de-referencing is undefined. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103750/new/ https://reviews.llvm.org/D103750 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits