middle-end/7018: incorrect bitfield handling
jbeulich@novell.com
jbeulich@novell.com
Thu Jun 13 09:31:00 GMT 2002
>Number: 7018
>Category: middle-end
>Synopsis: incorrect bitfield handling
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Thu Jun 13 08:26:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Jan Beulich
>Release: 3.1
>Organization:
>Environment:
cross compilers hosted on Cygwin (Win2K)
>Description:
The handling of bitfields where the type is wider than int,
but the actual width is narrower than int is incorrect in
that such bitfields are operated on as if they are ints.
While certainly one can say that this is an extension
anyway, having this inconsistent with the rest of the
language doesn't seem to make sense (and the whole point of
declaring a narrow bit field with a wide type is obviously
to force the compiler to perform calculations with the wider
precision), and the correction is simple.
>How-To-Repeat:
struct s {
unsigned long long uf:1;
};
unsigned long long utest(const struct s*ps) {
return ps->uf << 32;
}
>Fix:
In default_conversion, make the bit-field sub-clause
convert the type to [unsigned] int only when the original
type isn't wider, and use the wider type in the other cases.
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list