This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/54391] New: transparent_union typedef'ing inconsistent


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54391

             Bug #: 54391
           Summary: transparent_union typedef'ing inconsistent
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: devel@fresse.org


This works as expected:

union __attribute__((transparent_union)) m30_u {
    uint32_t u;
};

typedef union m30_u m30_t;

static inline double
make_double(m30_t m)
{
    return (double)m.u;
}

But typedef'ing upfront does not:

typedef union m30_u m30_t;

union __attribute__((transparent_union)) m30_u {
    uint32_t u;
};

static inline double
make_double(m30_t m)
{
    return (double)m.u;
}

...
uint32_t bar = 17;
make_double(bar);
....

transpu.c:27:2: error: incompatible type for argument 1 of 'make_double'
  printf("%.6f\n", make_double());
transpu.c:11:1: note: expected 'm30_t' but argument is of type 'uint32_t'

This is very inconsistent.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]