#include <new>
using namespace std;
void f(void*)
{}
struct A
{};
int main()
{
A a;
f((a.~A(), &a)); // OK
new (&a) A(); // OK
new ((a.~A(), &a)) A(); // error C2059: syntax error : 'type'
}
I think (a.~A(), &a) is a valid expression which can be evaluated to a pointer value, so it should be accepted as the placement argument, why is the result not so?
My compiler is VC++ 2013 RC. Is this a compiler bug?
Update:
I have summitted a bug to connect.microsoft.com
Yes, it is a compiler bug, the syntax is correct.
You can look at the grammar in the standard:
new-placement:
( expression-list )
And, a.~A(), &a
is valid as an expression-list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With