c/5593: GCC miscompiles bitshifts on unsigned struct members when creating a 64-bit value
bangerth@dealii.org
bangerth@dealii.org
Tue Nov 5 08:15:00 GMT 2002
Synopsis: GCC miscompiles bitshifts on unsigned struct members when creating a 64-bit value
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Tue Nov 5 08:15:02 2002
State-Changed-Why:
I can confirm this. However, I'm not sure whether what you
do is specified at all: it all boils down to this function:
long long equation4(struct field *data)
{
return ((long long)data->num << 32)|
(data->flags << 16)|
(data->container << 8)|
data->quantity;
}
and that data->flags is a 16-bit integer. I think, shifting
it by 16 is invoking undefined behavior, and you should
not be surprised. But then, I'm not a language lawyer and
leave this to someone else.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5593
More information about the Gcc-prs
mailing list