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.

The following sample generates C2716:

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

int main()
{
   V *pV = new V;   // C2716
   // try the following line instead
   // V *pV1 = __nogc new V;
}
Show: