www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1614] New: sizeof Gives Error When Used Inside an Inline Assembly Block

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

           Summary: sizeof Gives Error When Used Inside an Inline Assembly
                    Block
           Product: D
           Version: 2.007
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: johnkirollos yahoo.com


Statement like "mov ECX,float.sizeof;" is not accepted by the compiler: Error:
"ptr expected".

Consider the following example (same example used also in issue # 1500):

         ========================================
         void asm_template(T)(T Tval,T* pDest)
         {
                 asm{
                         fld Tval;
                         mov EAX,pDest;
                         fstp T ptr[EAX];        //#1
                         fstp float ptr[EAX];    //#2
                         mov EDX,T.sizeof;       //#3 (this statement is ok!)
                         mov ECX,float.sizeof;   //#4 (ERROR: "ptr expected")
                 }//asm
         }//asm_template

         void main()
         {
           float f1=4.0;
           float f2=5.0;

           asm_template!(float)(f1,&f2);
         }
         ========================================
 Here is the compilation result of the 4 statements marked above:
 #1: ERROR: "cannot use type float as an operand" (issue # 1500)
 #2: OK
 #3: OK!!!
 #4: ERROR: "ptr expected" (this issue)

Normally statement # 4 should be accepted, as 'float.sizeof' should be
translated into the value '4'.

Workaround:

    alias float.sizeof FLOAT_SIZE;
    ...
    mov EAX,FLOAT_SIZE;


-- 
Oct 26 2007
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1614


matti.niemenmaa+dbugzilla iki.fi changed:

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




------- Comment #1 from matti.niemenmaa+dbugzilla iki.fi  2007-10-26 13:10
-------


*** This bug has been marked as a duplicate of 1252 ***


-- 
Oct 26 2007