GCC complains about this code even though I compile with -std=c++11 flag, and my gcc version supposedly supports Unrestricted unions (>4.6).
union
{
struct
{
float4 I,J,K,T;
};
struct
{
float4 m_lines[4];
};
struct
{
float m16f[16];
};
struct
{
float m44f[4][4];
};
};
Note that float4 has a non-default constructor that takes 0 parameters.
class float4
{
public:
float4();
....
};
Any idea of what I could do ? The error is :
<anonymous union>::<anonymous struct>::I’ with constructor not allowed in anonymous aggregate
The issue here is not the fact that your class
float4has a constructor, making it a non-POD under the old C++03 definition of POD. Rather, the issue is that your union and the structs within your union are anonymous. If you simply name them, it will work: