Share via


Compiler Error C3534

a 'new expression' whose type contains 'auto' must have an initializer

If a new expression is used with the auto keyword and the default /Zc:auto compiler option, the new expression must specify an initializer.

To correct this error

  • Specify an initializer expression for the new operator.

Example

The following example demonstrates C3534. The first declaration does not yield an error because it has a direct initializer (0) whose type is int. The second declaration yields an error because it does not have an initializer. In the third declaration, the second use of the auto keyword yields an error because the new operator does not have an initializer.

// C3534.cpp
// Compile with /Zc:auto
int main()
{
   new auto(0); 
   new auto();          // C3534
   auto x = new auto(); // C3534
   return 0;
}

See Also

Reference

auto Keyword

operator new (<new>)