I have the following code:
#include "type_traits"
#include <new>
void foo()
{
std::aligned_storage<10,alignof(long)> storage;
new (&storage) int(12);
}
I have some storage defined (with length 10 bytes), and I am placement new
ing an int
into that location
gcc 7.3 gives the following warning:
<source>:10:10: warning: placement new constructing an object of type 'int' and size '4' in a region of type 'std::aligned_storage<10, 8>' and size '1' [-Wplacement-new=]
new (&storage) int(12);
If I am not incorrect this warning is incorrect. Am I missing something here or is this warning spurious?