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

            Bug ID: 71486
           Summary: Transparent union doesn't work with long double for
                    x86_64
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ubizjak at gmail dot com
  Target Milestone: ---

Following testcase:

--cut here--
union U { __int128 x; long double y; }  __attribute__ ((transparent_union));

void foo (union U);

void test (void)
{
  union U t;

  foo (1.0L);

  foo ( (__int128) 1);
}
--cut here--

gcc -O2:

union.c:1:7: warning: union cannot be made transparent
 union U { __int128 x; long double y; }  __attribute__ ((transparent_union));
       ^
 test
union.c: In function ‘test’:
union.c:9:3: error: incompatible type for argument 1 of ‘foo’
   foo (1.0L);
   ^
union.c:3:6: note: expected ‘union U’ but argument is of type ‘long double’
 void foo (union U);
      ^
union.c:11:3: error: incompatible type for argument 1 of ‘foo’
   foo ( (__int128) 1);
   ^
union.c:3:6: note: expected ‘union U’ but argument is of type ‘__int128’
 void foo (union U);
      ^

However, the test without transparent union:

--cut here--
union U { __int128 x; long double y; };

void foo (union U);

void test (void)
{
  union U t;

  t.y = 1.0L;
  foo (t);

  t.x = (__int128) 1;
  foo (t);
}
--cut here--

compiles OK.

Reply via email to