D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1500 - Template Arguments, Aliases, or Typedefs Generate Error when used inside inline ASM blocks
Summary: Template Arguments, Aliases, or Typedefs Generate Error when used inside inli...
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 All
: P3 enhancement
Assignee: No Owner
URL:
Keywords: iasm, rejects-valid, spec
Depends on:
Blocks:
 
Reported: 2007-09-13 17:40 UTC by John Kiro
Modified: 2019-08-08 13:38 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description John Kiro 2007-09-13 17:40:12 UTC
Best to describe it using an example. Here is a copy of the post I've put in D forum:

I made the following example to see how far can inline asm blocks use template args: (Note: This bugzilla is about statement #1 only. For #4, I'll open another one)
         ========================================
         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
                         mov ECX,float.sizeof;   //#4
                 }//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"
 #2: OK
 #3: OK!!!
 #4: ERROR: "ptr expected"

For me, if #1 would be illegal, then the error should not have mentioned "type float". In other words, why would it fail if T is correctly interpreted to float? In conclusion, it would make sense if such statement would be accepted, thus enabling writing general ASM code.
Comment 1 John Kiro 2007-10-27 13:56:34 UTC
The sizeof issue (line 4) is already opened (Issue # 1252).
Comment 2 Walter Bright 2012-01-21 19:56:58 UTC
Unfortunately, the grammar accepted by the inline assembler for expressions is not the regular D grammar. It's its own animal, for compatibility with the Intel syntax.

Improving it would be an enhancement request.
Comment 3 John Kiro 2012-02-24 07:28:53 UTC
Well, it was easy for me to figured out that it's tricky to correct :)
I'm not currently using pure assembly but I'll vote for it anyway. Guess it would require a certain number of votes to be taken into consideration.