This code generates the error message "const init" which doesn't make much sense.
(The "goto end" is only included to make it safe to run).
The same bug applies also to dd, ds, di, dl, de, df
(and to dw, dq, and dt, which are undocumented).
-------
void main()
{
goto end;
const byte z = 35;
asm { db z; }
end: ;
}
-------
And it would be nice if
asm { db 1+2; }
also worked (it currently prints "end of instruction").
There are two issues here: that this code fails to compile and that the mysterious message "const init" is in the compiler's repertoire. If there's any really invalid code that triggers this error, it needs to be replaced with something that makes sense.
Comment #3 by bugzilla — 2007-10-29T00:04:44Z
I can fix this particular problem (propagating const values), but generalized expressions for DB, etc., won't be supported until I get around to replacing the expression parser in the inline assembler with the full D expression parser.
Comment #4 by bugzilla — 2007-11-03T21:42:26Z
Fixed dmd 1.023 and 2.007
Comment #5 by clugdbug — 2009-04-15T05:41:33Z
I'm reopening this since there are 7 dstress bugs which depend on it.
asm_db_01_C in run/a/asm_db_01_C.d
asm_di_02_A in run/a/asm_di_02_A.d
asm_di_02_C in run/a/asm_di_02_C.d
asm_dl_02_A in run/a/asm_dl_02_A.d
asm_dl_02_C in run/a/asm_dl_02_C.d
asm_ds_01_A in run/a/asm_ds_01_A.d
asm_ds_01_C in run/a/asm_ds_01_C.d
Comment #6 by dlang-bugzilla — 2017-07-18T14:15:52Z
The original test case as presented in the issue description now works, as per comment 3, so I'm going to close this.
(In reply to Don from comment #5)
> I'm reopening this since there are 7 dstress bugs which depend on it.
DStress is no longer online, so these are no longer easily available.
Please reopen or file a new issue if you can provide a reproducible test case.
Comment #7 by smjg — 2017-07-18T20:26:49Z
(In reply to Vladimir Panteleev from comment #6)
> The original test case as presented in the issue description now works, as
> per comment 3, so I'm going to close this.
>
> (In reply to Don from comment #5)
> > I'm reopening this since there are 7 dstress bugs which depend on it.
>
> DStress is no longer online, so these are no longer easily available.
Doesn't follow - somebody might have a local copy of Dstress from back in the day. Indeed, I've found that I have. Not sure how complete it is, but I've found all of those listed in comment 5 therein. As I try under DMD 2.074, they all give a compile error.
Comment #8 by dlang-bugzilla — 2017-07-19T01:20:08Z
Stewart, "someone" is not enough. For a bug report to be useful, anyone should be able to reproduce the issue. There is very little value in keeping open a bug report where you have to go on an archaeology quest to find crucial details.
Since you still have the files, please attach them here (or to a new bug report)?
Comment #9 by dlang-bugzilla — 2017-07-19T02:26:22Z
OK, I got the Mercurial server running again, and uploaded a copy of the repository to GitHub. The files are here:
https://github.com/CyberShadow/dstress/tree/master/run/a
Still, looking at these test cases, it's still questionable whether there is much value in them. For instance, asm_di_02_A.d has:
const short x = 0x40404040;
This is clearly invalid code.
The `db 1+2` part of this issue is a valid enhancement request, but should be filed separately. If you have a need for the feature in your programs, please file a new enhancement request.