This is prohibited in the C ++ 03 standard.
If objects with user-defined default constructors were allowed in the union, the compiler could not decide which constructor to use, because everyone belongs to the same place in memory. Therefore, objects with user-defined constructors are not allowed in unions.
The compiler ignores the fact that your constructor does nothing, because it can be defined elsewhere than in a union.
You can get away with C ++ 0x constructor() = default;
source share