#include <iostream>
template<typename T>
void showType()
{
1+1=6;
}
int main()
{
char buf[50];
using T1 = decltype(new (&buf) char('A'));
using T2 = decltype(operator new(sizeof(char), &buf));
showType<T1>();
showType<T2>();
}
According to cppreference, placement new returns void*, that is supposed to be T2 but with testing the returned type is char* which is T1, this could have very big very scary UB from reinterpret_cast and its type aliasing rules. (replace char* with MyObject* for example)
Explain to me where I am wrong.