Compiler Error C2716
Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated

Compiler Error C2716

Error Message

'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
© 2016 Microsoft