https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114066

            Bug ID: 114066
           Summary: Allow classes with constructors in anonymous struct
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redorav at gmail dot com
  Target Milestone: ---

Hi,

I am aware that the standard does not mandate allowing members with
constructors in anonymous structs and in this case GCC does not support it, but
I would like to request the feature. I am also aware of 86001 which looks
similar (but is a question) and 77314, which requests support for POD types.
However I'm looking for the full thing.

My use case is a math library, hlsl++, where in AVX mode I alias a single m256
with two m128 members. This is so that I can support matrix swizzles. The
internal structure of float4x4 looks conceptually like this (simplified):

template<int X, int Y, int Z, int W>
struct swizzle4
{
    swizzle& operator = (const swizzle& other) // Do swizzle things

    m128 s;
};

float4x4
{
    union
    {
        m256 vec;
        struct
        {
             swizzle4<0, 1, 2, 3> _m00_m10_m20_m30;
             swizzle4<0, 1, 2, 3> _m01_m11_m21_m31;
        };
    };
};

The swizzles are meant to be able to manipulate the data via rows (e.g. setting
a transformation matrix). If there is a better way to do this I don't really
know how, and so far this has been succesful in other compilers and seems like
a nice way to do it. If it was possible to support it in the same way unions
support it it'd be a nice addition.

Thanks

Reply via email to