Re: Rant and proposal about bitfield semantics in our IL and the C/C++ Frontend

2008-01-15 Thread Joseph S. Myers
On Tue, 15 Jan 2008, Michael Matz wrote: > Doing arithmetic on small bit-fields on the (larger) promoted type, but > doing them on large bit-fields on the exact width creates an asymmetry. It's the same as arithmetic on unsigned short actually being done on the promoted type (signed int), whi

Re: Rant and proposal about bitfield semantics in our IL and the C/C++ Frontend

2008-01-15 Thread Michael Matz
Hi, On Tue, 15 Jan 2008, Joseph S. Myers wrote: > On Mon, 14 Jan 2008, Richard Guenther wrote: > > > Can you clarify on the resulting promotions? As I remember the > > standard defines promotions based on the representable values, so > > long : 15 gets promoted to int, but long : 33 doesn't get

Re: Rant and proposal about bitfield semantics in our IL and the C/C++ Frontend

2008-01-15 Thread Richard Guenther
On Tue, 15 Jan 2008, Joseph S. Myers wrote: > On Mon, 14 Jan 2008, Richard Guenther wrote: > > > Can you clarify on the resulting promotions? As I remember the > > standard defines promotions based on the representable values, so > > long : 15 gets promoted to int, but long : 33 doesn't get prom

Re: Rant and proposal about bitfield semantics in our IL and the C/C++ Frontend

2008-01-14 Thread Joseph S. Myers
On Mon, 14 Jan 2008, Richard Guenther wrote: > Can you clarify on the resulting promotions? As I remember the > standard defines promotions based on the representable values, so > long : 15 gets promoted to int, but long : 33 doesn't get promoted. > In the C++ FE at least we promote to the _decla

Re: Rant and proposal about bitfield semantics in our IL and the C/C++ Frontend

2008-01-14 Thread Alexandre Oliva
On Jan 14, 2008, Richard Guenther <[EMAIL PROTECTED]> wrote: > The question arises when computing the value of say long : 33 i; > i << 16 >> 16. Is the shift performed in long : 33 type? Is an > out-of-range value truncated? If truncation makes any difference, then there must have been overflow

Re: Rant and proposal about bitfield semantics in our IL and the C/C++ Frontend

2008-01-14 Thread Richard Guenther
On Mon, 14 Jan 2008, Joseph S. Myers wrote: > On Mon, 14 Jan 2008, Richard Guenther wrote: > > > - document how integral promotion is performed on the implementation > >defined bitfields we allow as a GNU extension. (4.9, "Integer > >promotion rules are extended for non-standard bit-fie

Re: Rant and proposal about bitfield semantics in our IL and the C/C++ Frontend

2008-01-14 Thread Joseph S. Myers
On Mon, 14 Jan 2008, Richard Guenther wrote: > - document how integral promotion is performed on the implementation >defined bitfields we allow as a GNU extension. (4.9, "Integer >promotion rules are extended for non-standard bit-field types to >promote to the smallest integer type t

Rant and proposal about bitfield semantics in our IL and the C/C++ Frontend

2008-01-14 Thread Richard Guenther
Consider struct s { long a : 33; }; long bar(struct s *x) { return (x->a << 16) >> 16; } extern void abort(void); int main() { struct s a = { 1u << 31 }; if (bar(&a) != 0) abort (); return 0; } where we currently (rightfully so, IMHO) abort. There are several prob