Avviso del compilatore (livello 2) C4345

Aggiornamento: novembre 2007

Messaggio di errore

modifica del comportamento: per impostazione predefinita verrà inizializzato un oggetto di tipo POD costruito con un inizializzatore con formato ()
behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized

In questo avviso viene comunicata una modifica del comportamento rispetto al compilatore Visual C++ fornito in Visual Studio .NET al momento dell'inizializzazione di un oggetto POD con (). Il compilatore inizializzerà l'oggetto per impostazione predefinita.

Per ulteriori informazioni, vedere Riepilogo delle ultime modifiche in fase di compilazione.

Nell'esempio seguente viene generato l'errore C4345:

// C4345.cpp
// compile with: /W2
#include <stdio.h>

struct S* gpS;

struct S
{
   // this class has no user-defined default ctor
   void *operator new (size_t size, void*p, int i)
   {
      ((S*)p)->i = i;   // ordinarily, should not initialize
                        // memory contents inside placement new
      return p;
   }
   int i;
};

int main()
{
   S s;
   // Visual C++ .NET 2003 will default-initialize pS->i
   // by assigning the value 0 to pS->i.
   S *pS2 = new (&s, 10) S();   // C4345
   // try the following line instead
   // S *pS2 = new (&s, 10) S;   // not zero initialized
   printf("%d\n", pS2->i);
}