Bug 2455 – Cannot use .ptr or .length in asm code

Status
RESOLVED
Resolution
WONTFIX
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-11-14T23:02:03Z
Last change time
2020-03-21T03:56:35Z
Keywords
iasm, rejects-valid
Assigned to
No Owner
Creator
Don

Comments

Comment #0 by clugdbug — 2008-11-14T23:02:03Z
This was first reported in #1125 as failed workaround. I'm moving it here since the original bug in #1125 was fixed long ago. It's in dstress as: http://dstress.kuehne.cn/run/t/tuple_23_C.d It's probably related to #1252, #1172, and #1173. It seems that fullstops ('.') are not treated correctly. #1500 may also be related. void foo(int [] q) { asm{ mov EAX, q.ptr; // mov ECX, q.length; // this doesn't work either } } There aren't any good workarounds for this. Creating a local variable and using 'naked' are the two best options, but they're both ugly.
Comment #1 by b2.temp — 2019-07-23T01:52:23Z
D expressions allowed as asm operands must give either directly a variable or must evaliate to a constant known at compile time (limited to type property for now). .length / .ptr is already more complex and requires an offset.