Compiler Error C3257
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Compiler Error C3257

Error Message

'object' : explicit call to ctor of __gc class type not allowed (did you forget 'new'?)

You cannot create temporary stack-based objects for managed classes. The compiler attempted to create a temporary object that is not directly mentioned in the code. This temporary object is created on the stack because there is no call to new.

C3257 is only reachable using /clr:oldSyntax.

The following sample generates C3257:

// C3257a.cpp
// compile with: /clr:oldSyntax /c
__gc class X {
   X(int i) {
      X();   // C3257
      X *MyX = new X();   // OK
© 2015 Microsoft