[Issue 1614] New: sizeof Gives Error When Used Inside an Inline Assembly Block
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 26 08:53:20 PDT 2007
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 at digitalmars.com
ReportedBy: johnkirollos at 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;
--
More information about the Digitalmars-d-bugs
mailing list