Just add more information on this subject for MSVC and g ++ and repeat what @Charles Bailey and @ René Richter said; Its acceptable are C ++ 03 and C ++ 11, but depending on the age and implementation status of your compiler, you will get different errors, if at all.
In fact, I tried the Dinkum online testing compilers for EDG, MSVC2008 and g ++, and everyone compiled the sample you gave, but NOT the sample I give below.
So, in short, fully initialized structures with constant members will successfully compile on MSVC2008 and g ++ 4.5, however, from proven compilers, no one can compile “partially initialized” (or partially aggregate initialized) POD structures, even if this is also acceptable in the C ++ standard. I even contacted some supporting g ++ errors to make sure I read this standard correctly and they confirmed that it should work even in current C ++ 03 compilers.
You can see related errors for this on both GNU Bugzilla and the Microsoft Visual Studio Help pages that were actually related to this fooobar.com/questions/895617 / ... , which is also related to Microsoft Error C3852 as a known behavior even MSVC2010
// All sections refer to Draft C++03 (brackets refer to draft C++11) // // 3.9.3 CV (const/volatile) definition as "const data-type [= optional init]" // 7.1.5.1/1 The cv-qualifiers [ 7.1.6.1/1 in C++11 ] // "init-declarator-list of the declaration shall not be empty" const int constval = 10 ; // HOWEVER: // 7.1.5.1/2 The cv-qualifiers [ 7.1.6.1 in C++11 ] // [Note: as described in 8.5, the definition of an object or subobject // of const-qualified type must specify an initializer or be subject to // default-initialization. ] // 8.5 Initializers // 8.5/9 (C++11 8.5/11) // Otherwise, if no initializer is specified for a non-static // object, the object and its sub-objects, if any, have an indeterminate // initial value(*90); if the object or any of its sub-objects are of // const-qualified type, the program is ill-formed. // // *90: This does not apply to aggregate objects with automatic storage // duration initialized with an incomplete brace-enclosed initializer list // see 8.5.1. // [ C++11 this sub-clause has been removed, however the list-initializer section // pretty much covers the same topic - see 8.5.1/7 below ] // // 8.5.1 Aggregate definition // 8.5.1/7 (C++11 8.5.1/7) // If there are fewer initializers in the list than there are members in the // aggregate, then each member not explicitly initialized shall be // value-initialized (8.5). // // 8.5/5 value initialization // if T is a class type (clause 9) with a user-declared constructor // (12.1), then the default constructor for T is called (and the // initialization is ill-formed if T has no accessible default constructor) // ... // otherwise, the object is zero-initialized // // 8.5/5 zero initialization // if T is a scalar type (3.9), the object is set to the value of 0 (zero) converted to T; // // POD type struct A { int n ; const int m ; // "const" causes failure in MSVC to make default constructor } ; // Example of non-POD struct B { int bbb ; B(){} } ; #include <stdio.h> int main() { // C++03/11 ill formed code, fails as expected const int c0 ; // per 7.1.5.1 "not allowed to be default init" // OK const int c = *new int ; // A default initialized constant const int c2 = *new int(); // A zero-init, above is DEFAULT-INIT printf( "c: %i\n", c ) ; // should be an undef-value printf( "c2: %i\n", c2 ) ; // should be 0 // OK ; Array example making sure it works const int aa[5] = {}; // all items value->zero-initialized per the above 8.5.1/7 printf( "aa: %i %i %i\n", aa[0], aa[2], aa[4] ) ; // C++03/11 ill formed code, no initializer (G++/MSVC should fail) A a0 ; // Correct error - no default constructor or initializer (8.5/9) // C++03/11 correctly formed code, full initializer list (G++/MSVC should pass) A a1 = {1,2}; // Explicit initialization OK, G++/MSVC pass // C++03/11 correctly formed code; copy initialized from a value-initialized A() A a2 = A(); // G++ OK, MSVC FAIL // C++03/11 correctly formed code; aggregate partial intializer (8.5.1/7 agg list init) A a3 = {}; // G++/MSVC FAIL A a4{}; // C++11 only - doesnt work in G++ (didnt try MSVC2010) printf( "a0.m=%i\n", a0.m ) ; // a0 should not exist due compile errors printf( "a1.m=%i\n", a1.m ) ; // a1.m should be 2 printf( "a2.m=%i\n", a2.m ) ; // a2.m should be 0 printf( "a3.m=%i\n", a3.m ) ; // a3.m should be 0 // C++03/11 correctly formed code; user-default constructor supplied. const B bee1 ; // Default constructor marks bbb as "initialized" const B bee2 = {} ; // CORRECTLY flagged error; init of non-aggregate printf( "%i\n", bee1.bbb ) ; }