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

            Bug ID: 88955
           Summary: transparent_union for vector types not accepted
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amonakov at gcc dot gnu.org
  Target Milestone: ---

GCC (and Clang) rejects an attempt to create a transparent union corresponding
to an SSE register:

typedef unsigned long u64x2 __attribute__ ((vector_size (16)));

typedef union
__attribute__((transparent_union))
{
        u64x2   u64;
} v128;

The diagnostic is not very clear about the reason:

union.i:3:9: warning: union cannot be made transparent

Looking in gdb, it appears that the union has mode TI, while its TYPE_FIELDS
has V2DI mode.

Adding a dummy __int128 field makes GCC accept the code (but such workaround
won't work for wider vectors, or on 32-bit).

The intended usecase for this is a vector union type for easier interop between
Intel intrinsics and user code written with generic vectors, as suggested by
Richard in https://gcc.gnu.org/ml/gcc-patches/2019-01/msg01186.html

Reply via email to