This documentation is archived and is not being maintained.

Compiler Error C2716

'operator new' allocates value types on the C++ heap; use '__nogc new type'

The syntax of an object instantiation was incorrect.

C2716 is only reachable using /clr:oldSyntax.

The following sample generates C2716:

// C2716.cpp
// compile with: /clr:oldSyntax
#using <mscorlib.dll>
__value struct V {};

int main() {
   V *pV = new V;   // C2716
   V *pV1 = __nogc new V;   // OK