GtkD compile failed. shift by 32

Jonathan M Davis jmdavisProg at gmx.com
Sun Jun 10 18:29:24 PDT 2012


On Sunday, June 10, 2012 20:21:29 1100110 wrote:
> http://svn.dsource.org/projects/gtkd/branches/070125merge/gtkD/src/gdk/Color
> .d
> 
> 
> uint getValue()
> {
> 	return (gdkColor.red <<32) | (gdkColor.green << 16) | (gdkColor.blue);
> }
> 
> 
> Just browsing through the source it looks like gtkColor.red is a ushort.
> I get this error.
> 
> dmd -O -m64 -Isrc -c src/gdk/Pixbuf.d -ofsrc/gdk/Pixbuf.o
> src/gdk/Color.d(231): Error: shift by 32 is outside the range 0..31
> make: *** [src/gdk/Color.o] Error 1
> make: *** Waiting for unfinished jobs....
> ==> ERROR: A failure occurred in build().
> 
> I get that exact same message no matter which compiler I use.
> 
> Does any

I take it that part of you post got cut off?

In either case,

* ulong can only be shifted by up to 63 bits
* uint can only be shifted by up to 31 bits
* ushort can only be shifted by up to 15 bits
* ubyte can only be shifted by up to 7 bits

Any code which attempts to shift by more than that is wrong. If you want to 
shift a value by the number of bits in its type, you might as well just use 0. 
If gtkD is attempting to shift by more than is legal, then it has a bug.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list