Bug 5302 – Inline assembler: Indexing struct fields not possible inside member function

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2010-12-01T10:21:53Z
Last change time
2020-08-21T06:42:32Z
Keywords
bootcamp, iasm
Assigned to
No Owner
Creator
Harry Vennik

Attachments

IDFilenameSummaryContent-TypeSize
836iasm_test.dFailing codetext/plain184

Comments

Comment #0 by htvennik — 2010-12-01T10:21:53Z
@ DMD 2.050 An instruction like: mov EAX, Struct.field[EDX]; compiles OK in free functions, but when inside a member function, the compiler complains about a wrong type of 'this' for type Struct.
Comment #1 by bearophile_hugs — 2010-12-01T12:29:54Z
Please, if possible add a complete minimal program that shows the problem.
Comment #2 by htvennik — 2010-12-02T07:52:48Z
Created attachment 836 Failing code
Comment #3 by htvennik — 2010-12-02T07:55:26Z
Comment on attachment 836 Failing code Compiling this results in the following error message: iasm_test.d(15): Error: this for i needs to be type S not type iasm_test.A iasm_test.d(15): bad type/size of operands '(__error).i'
Comment #4 by bugzilla — 2020-08-20T08:48:46Z
The attachment: module iasm_test; struct S { uint i; } class A { uint func(S* s) { asm { mov EDX, s; mov EAX, S.i[EDX]; } } }
Comment #5 by bugzilla — 2020-08-21T06:42:32Z
The parser for the iasm operator expressions is quite limited compared with the regular D expressions is quite limited. It is also different in order to be like the Intel assembler syntax. However, this case can be handled using: mov EAX, S.i.offsetof[EDX]; instead of: mov EAX, S.i[EDX]; Marked as invalid because there is a way to make it work.