[RFA] Setting long long bitfields

Andreas Schwab schwab@suse.de
Mon Nov 1 02:48:00 GMT 2004


Paul Hilfinger <hilfingr@EECS.Berkeley.EDU> writes:

>  > > One possible tweak, several of us have an aversion to "?:", it would be
>  > > nice if it wasn't there :-)
>  > 
>  > Like this perhaps:
>  > 
>  > +  ULONGEST mask = (ULONGEST) -1 >> (8 * sizeof (ULONGEST) - bitsize);
>
> Andreas,
>
> I had considered exactly that line, but unfortunately ran across the
> following really irritating provision in the C standard:
>
>     "If the value of the right operand is negative or is 
>      *greater than or equal to* the width of the promoted left
>      operand, the behavior is undefined."

That cannot happen, because bitsize will never be zero.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Gdb-patches mailing list