Re: Removing undefined behavior of bitshifts

2011-06-11 Thread Paul D. Anderson
Timon Gehr Wrote: > Timon Gehr wrote: > > On 07/06/2011 00:20, Timon Gehr wrote: > > > >> I'd much prefer the behavior to be defined as 1< >> 1<<(0x1f&x); (That's what D effectively does during runtime. It is also > >> what > >> the machine code supports, at least in x87). > > > > Defining the b

Re: Removing undefined behavior of bitshifts

2011-06-11 Thread s_lange
Am 09.06.2011 09:08, schrieb Don: s_lange wrote: As of yet, there are only general-pupose integer rotate instructions on x86 processors, and very few other CPUs and µCs actually implement rotate instructions. Really? Itanium, PowerPC, ARM, 6502, Z80, PIC all have rotate instructions. I've nev

Re: Removing undefined behavior of bitshifts

2011-06-11 Thread Timon Gehr
Timon Gehr wrote: > On 07/06/2011 00:20, Timon Gehr wrote: > >> I'd much prefer the behavior to be defined as 1<> 1<<(0x1f&x); (That's what D effectively does during runtime. It is also what >> the machine code supports, at least in x87). > > Defining the behaviour to match that of one brand of pr

Re: Removing undefined behavior of bitshifts

2011-06-11 Thread Stewart Gordon
On 07/06/2011 00:20, Timon Gehr wrote: I'd much prefer the behavior to be defined as 1< Defining the behaviour to match that of one brand of processor would be arbitrary and confusing. Why not define it just to shift by the requested number of bits? Any extra processor instructions to make

Re: Removing undefined behavior of bitshifts

2011-06-09 Thread Don
s_lange wrote: Am 07.06.2011 01:20, schrieb Timon Gehr: I'd much prefer the behavior to be defined as 1<1<<(0x1f&x); (That's what D effectively does during runtime. It is also what the machine code supports, at least in x87). Well, you probably mean what x86 processors do. The behaviour of x

Re: Removing undefined behavior of bitshifts

2011-06-07 Thread s_lange
Am 07.06.2011 01:20, schrieb Timon Gehr: I'd much prefer the behavior to be defined as 1< Well, you probably mean what x86 processors do. The behaviour of x86 processors in this regard is (at leas) well defined, but not uniform. It all depends whether you use general-purpose integer instructio

Re: Removing undefined behavior of bitshifts

2011-06-07 Thread Timon Gehr
Vladimir Panteleev wrote: > On Tue, 07 Jun 2011 02:20:17 +0300, Timon Gehr wrote: > >> I'd much prefer the behavior to be defined as 1<> 1<<(0x1f&x); (That's what D effectively does during runtime. It is also >> what the machine code supports, at least in x87). > > Can you think of any cases wher

Re: Removing undefined behavior of bitshifts

2011-06-06 Thread Vladimir Panteleev
On Tue, 07 Jun 2011 02:20:17 +0300, Timon Gehr wrote: Currently, the behavior of a shift by more than the size in bytes of the operand is undefined. (Well, it's an 'error', but unchecked.) Also see http://d.puremagic.com/issues/show_bug.cgi?id=4887 -- Best regards, Vladimir

Re: Removing undefined behavior of bitshifts

2011-06-06 Thread Vladimir Panteleev
On Tue, 07 Jun 2011 02:20:17 +0300, Timon Gehr wrote: I'd much prefer the behavior to be defined as 1<1<<(0x1f&x); (That's what D effectively does during runtime. It is also what the machine code supports, at least in x87). Can you think of any cases where this overflow behavior would be ex

Removing undefined behavior of bitshifts

2011-06-06 Thread Timon Gehr
Currently, the behavior of a shift by more than the size in bytes of the operand is undefined. (Well, it's an 'error', but unchecked.) int x=32; x=1<