bug fix for c-torture test execute/bf-sign-2.c
Jeffrey A Law
law@cygnus.com
Mon Feb 2 00:57:00 GMT 1998
In message <199710241101.MAA17399@phal.cygnus.co.uk>you write:
> > > The 31 bit unsigned bitfield is promoted to unsigned long int, not
> > > signed long int. Hence the check fails. I found this for the d10v
> > > port (which also supports 64 bit long long), and then checked the h83
> 00:
> > > it does the promotion the same way (but it doesn't show for a torture
> > > test because the h8300 has only 32 bit long long, hence the test is s
> kipped).
> > Seems to me that the bug is in the compiler, not the test.
> >
> > Yes, ANSI doesn't mandate we handle this case since ANSI doesn't handle a
> > bitfied > sizeof (int), but we want to do the "expected thing" if possibl
> e.
> >
> > So, it would seem to me, that for a 16bit int/32bit long target that a
> > 31bit unsigned long field should promote to a "signed long" type.
>
> Ok. Here is a patch to implement this:
>
> Fri Oct 24 11:52:29 1997 J"orn Rennecke <amylaar@cygnus.co.uk>
>
> * c-typeck.c (default_conversion): If ints are smaller than
> 32 bit, promote bitfields larger than int, but smaller than
> long to long / unsigned long.
I think this needs to be reworked slightly to not be so 32bit specific.
ANSI states that a integral value is promoted to an int if an int
can represent all the values that the original value could have
otherwise it is promoted to an unsigned int.
We should promote items to long long and unsigned long long in
the same manner. ie, if the value will fit into whatever size
a long long happens to be, then use long long, else use an
unsigned long long.
Note that this says nothing about the actual bitsize of the items in
question. But your patch had some special checks for 32bit ints
and such.
jeff
More information about the Gcc
mailing list