[Issue 8497] New: Bad code gen involving ubyte, ternary operators, and shifts

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 2 13:23:14 PDT 2012


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

           Summary: Bad code gen involving ubyte, ternary operators, and
                    shifts
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Mac OS X
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: peter.alexander.au at gmail.com


--- Comment #0 from Peter Alexander <peter.alexander.au at gmail.com> 2012-08-02 13:23:12 PDT ---
Sorry for the title, don't know how to describe this well:

------------------
class Foo
{
public:
    void foo(uint value)
    {
        ubyte size = value < (0x7fU << 0 ) ? 1 :
                     value < (0x7fU << 14) ? 2 :
                                             3;
        import std.stdio;
        writeln(size);
    }
}

void main()
{
    Foo f = new Foo();
    f.foo(1000000);
}
------------------

With no optimisations or any other flags, this prints out 255, even though it
should print 2.

Happens in DMD 2.060, but not 2.059.

-- 
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