[Issue 4887] Right-shifting by 32 is allowed and broken

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 3 18:41:12 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4887


Austin Hastings <ah08010-d at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ah08010-d at yahoo.com


--- Comment #8 from Austin Hastings <ah08010-d at yahoo.com> 2010-10-03 18:40:49 PDT ---
I encountered a similar problem. I was taking code I had written with ulongs
and trying to template-ize the code. For me, the code below prints "plain
error?".
======
import std.stdio;

void main() {
    uint foo = 0;

    plain_sub( foo );
}

int plain_sub( const uint value ) {

    if( uint t32 = value >> 32 ) {
        writeln( "plain error?" );
    }

    return 0;
}
=====
C99 says that shifts >= the width of the victim are undefined behavior. The D2
manual says shifting /more/ than the width of the victim is illegal. 

Apparently, shifting equal to the width is legal-but-surprising. I'd like it to
be either illegal, with a warning, or legal-but-not-surprising.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list