Return value of placement new
<p>Consider the following C++14 code:</p>

<pre><code>#include &lt;cassert&gt;
#include &lt;new&gt;
#include &lt;type_traits&gt;

struct NonStandardLayout
{
    // ...
};

int main()
{
    using T = NonStandardLayout;

    std::aligned_storage_t&lt; sizeof(T), alignof(T) &gt; storage;
    T *const valid_ptr = new(static_cast&lt;void *&gt;(&amp;storage)) T;

    T *const maybe_ptr = reinterpret_cast&lt;T *&gt;(&amp;storage);
    assert(maybe_ptr == valid_ptr); // ???

    valid_ptr-&gt;T::~T();
    return 0;
}
</code></pre>

<p>Is it guaranteed by the standard that the assert in the example will never fail, for any type T?</p>

<h2>Discussion</h2>

<p>Looking in the latest standard (<a href="http://eel.is/c++draft/" rel="noreferrer">http://eel.is/c++draft/</a>), I cannot see any reference to this particular scenario but I have found the following paragraphs that arguably points to the answer 'yes'.</p>

<p>Is it correct of me to think that
[expr.new/15]
and
[new.delete.placement/2]
together states that the value of <code>valid_ptr</code> will equal the address of <code>storage</code>, always?</p>

<p>If so, is it true that the <code>reinterpret_cast</code> will yield a pointer to a fully constructed object? Because,
[expr.reinterpret.cast/7],
[expr.static.cast/13]
and
[basic.compound/4]
together seem to indicate that it should be the case.</p>

<p>From my observations, library implementations of the default allocator seem to cast similar to this and without worry! Is it <em>really</em> safe to cast like this?</p>

<p>How can we be sure that the two pointers will be the same, or can we?</p>