Thread overview
[Issue 1500] New: Template Arguments, Aliases, or Typedefs Generate Error when used inside inline ASM blocks
Sep 13, 2007
d-bugmail
Oct 27, 2007
d-bugmail
Jan 22, 2012
Walter Bright
Feb 24, 2012
John Kiro
September 13, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1500

           Summary: Template Arguments, Aliases, or Typedefs Generate Error
                    when used inside inline ASM blocks
           Product: D
           Version: 1.015
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid, spec
          Severity: major
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: johnkirollos@yahoo.com


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.


-- 

October 27, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1500





------- Comment #1 from johnkirollos@yahoo.com  2007-10-27 13:56 -------
The sizeof issue (line 4) is already opened (Issue # 1252).


-- 

January 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=1500


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com
            Version|1.015                       |D1 & D2
         OS/Version|Linux                       |All
           Severity|major                       |enhancement


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2012-01-21 19:56:58 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 24, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=1500



--- Comment #3 from John Kiro <johnkirollos@yahoo.com> 2012-02-24 07:28:53 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------