Bug 8088 – Inline assembler: Indexing struct fields not possible
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-05-11T20:37:14Z
Last change time
2020-03-21T03:56:37Z
Keywords
iasm, rejects-valid
Assigned to
No Owner
Creator
Denis Shelomovskii
Comments
Comment #0 by verylonglogin.reg — 2012-05-11T20:37:14Z
Example from http://dlang.org/iasm.html:
---
struct Foo { int a,b,c; }
int bar(Foo *f) {
asm {
mov EBX, f;
mov EAX, Foo.b[EBX];
}
}
---
main.d(5): Error: variable b cannot be read at compile time
Also see Issue 5302
Workaround: add .offsetof
Comment #1 by b2.temp — 2019-07-23T01:12:48Z
The spec says that this syntax only works in the scope of the aggregate. Not the case here.