c++ - Constructor and anonymous union with const members -


is possible have anonymous union const members? have following:

struct bar {   union {     struct { const int x, y; };     const int xy[2];   };   bar() : x(1), y(2) {} }; 

with g++ 4.5 error:

error: uninitialized member ‘bar::<anonymous union>::xy’ ‘const’ type ‘const int [2]’ 

this problem in gcc fixed in version 4.6. code works fine.

it still depends on gcc extension because uses anonymous struct, compilers support them now. also, following code builds -pedantic:

struct bar {   union {     const int x;     const int y;   };   bar() : x(1) {} }; 

that code accepted clang , visual studio 2010 (but fails 2008).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -