www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18373] New: The inline assembler parser allows strange

https://issues.dlang.org/show_bug.cgi?id=18373

          Issue ID: 18373
           Summary: The inline assembler parser allows strange constructs
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: accepts-invalid, iasm
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

Example 1/

void foo()
{
    asm pure nothrow
    {
        naked;
        mov RAX, [0x10][0x20] R8;
        ret;
    }
}

generates:

;------- SUB 0000000000449468h -------
0000000000449468h  mov eax, 00000030h
000000000044946Dh  ret
;-------------------------------------

Example 2/

void foo()
{
    asm pure nothrow
    {
        naked;
        mov RAX, [R9][R10] R8;
        ret;
    }
}

generates:

;------- SUB 0000000000449468h -------
0000000000449468h  mov rax, r8
000000000044946Bh  ret
;-------------------------------------

And the best for the end ;)

void foo()
{
    asm pure nothrow
    {
        naked;
        mov RAX[R8][R12], [0x10][0x20] DX [0x10][0x20];
        ret;
    }
}

generates:

;------- SUB 0000000000449468h -------
0000000000449468h  mov eax, 00000060h
000000000044946Dh  ret 
;-------------------------------------


All of them should be detected as error, at some point.
Maybe after iasm parsing since recursive nature of the parser may allow this.

--
Feb 05