www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2133] New: anonymous enum without {} doesn't work as asm value

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2133

           Summary: anonymous enum without {} doesn't work as asm value
           Product: D
           Version: 2.014
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: chris edesix.com


The anonymous enum syntax allows the {} to be omitted if there is only one
value, as described under "Manifest Constants" in the spec. However, they seem
to behave differently to single value anonymous enums that do have braces when
used as immediate values in the inline assembler. Test case...

import std.string;

enum n1 = 42;
enum { n2 = 42 }

uint retN1() {
    asm {
        mov EAX,n1; // No! - mov EAX,-4[EBP]
    }
}

uint retN2() {
    asm {
        mov EAX,n2; // OK - mov EAX,02Ah
    }
}

unittest {
    assert( retN1() == 42, "expected 42, got "~toString( retN1() ) );
    assert( retN2() == 42, "expected 42, got "~toString( retN2() ) );
}

void main() {}


-- 
May 27 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2133


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed dmd 2.015


-- 
Jun 22 2008