www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8497] New: Bad code gen involving ubyte, ternary operators, and shifts

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: peter.alexander.au gmail.com



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: -------
Aug 02 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8497




13:27:47 PDT ---
Dissassembly:

_D4test3Foo3fooMFkZv:
00000001000007b0    pushq   %rbp
00000001000007b1    movq    %rsp,%rbp
00000001000007b4    subq    $0x18,%rsp
00000001000007b8    pushq   %rbx
00000001000007b9    movl    %esi,0xf8(%rbp)
00000001000007bc    testq   %rdi,%rdi
00000001000007bf    jne     0x1000007f6
00000001000007c1    movl    $0x00000004,%r8d
00000001000007c7    movq    0x00022b5a(%rip),%rcx
00000001000007ce    movq    0x00022b4b(%rip),%rax
00000001000007d5    movq    %rax,%rdx
00000001000007d8    movq    %rdx,0xe8(%rbp)
00000001000007dc    movq    0x00022b65(%rip),%rdx
00000001000007e3    movq    0x00022b56(%rip),%rdi
00000001000007ea    movq    %rdx,%rsi
00000001000007ed    movq    0xe8(%rbp),%rdx
00000001000007f1    callq   0x10002189a ; symbol stub for: __d_assert_msg
00000001000007f6    callq   0x1000217e0 ; symbol stub for:
_D9invariant12_d_invariantFC6ObjectZv
00000001000007fb    movl    0xf8(%rbp),%ebx
00000001000007fe    cmpl    $0x7f,%ebx
0000000100000801    movl    $0x00000001,%esi
0000000100000806    jb      0x100000813
0000000100000808    cmpl    $0x001fc000,%ebx
000000010000080e    sbbl    %esi,%esi
0000000100000810    addb    $0x03,%dh
0000000100000813    movq    %rsi,%rdi
0000000100000816    callq   0x100021282 ; symbol stub for:
_D3std5stdio14__T7writelnThZ7writelnFhZv
000000010000081b    popq    %rbx
000000010000081c    leave
000000010000081d    ret

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 02 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8497


Bernard Helyer <blood.of.life gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |blood.of.life gmail.com



19:37:55 PDT ---
Same thing happens over here in Linux.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 02 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8497




Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/9b3a8aa4e82a85d2392ad4e2c103157284c47665
fix Issue 8497 - Regression 2.060: Bad code gen involving ubyte, ternary
operators, and shifts

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8497




Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/9b3a8aa4e82a85d2392ad4e2c103157284c47665
fix Issue 8497 - Regression 2.060: Bad code gen involving ubyte, ternary
operators, and shifts


Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/fa6c7fb523455743f29bb944100e3617de594cbc
fix Issue 8497 - Regression 2.060: Bad code gen involving ubyte, ternary
operators, and shifts

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 04 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8497


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



17:48:01 PDT ---
Not a regression, but fixed anyway.

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