Bug 19190 – pragma(msg) changes the semantics of a program

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-08-25T15:31:24Z
Last change time
2024-12-13T19:00:20Z
Assigned to
No Owner
Creator
Yuxuan Shui
Moved to GitHub: dmd#19478 →

Comments

Comment #0 by yshuiv7 — 2018-08-25T15:31:24Z
Reduced example: struct lr1 { lr1* a; } template proxy(T) { static if (is(typeof(gen!T.str))) enum str = gen!T.str; } template gen(T) if (is(T == struct)) { enum str = T.stringof; private enum xstr = gen!(lr1*).str; } template gen(T: S*, S) { private alias rc = proxy!S; //pragma(msg, __traits(allMembers, rc)); <- uncomment this line resolves error enum str = rc.str~"_ptr"; } enum tmp = proxy!lr1.str;
Comment #1 by yshuiv7 — 2018-08-25T15:51:26Z
Sorry, wrong version of the code is attached. Here is the offending code: struct lr1 { lr1* a; } template proxy(T) { private alias G = gen!T; static if (is(typeof(G.str))) enum str = G.str; } template gen(T) if (is(T == struct)) { enum str = T.stringof; private enum xstr = gen!(lr1*).str; } template gen(T: S*, S) { private alias rc = proxy!S; //pragma(msg, __traits(allMembers, rc)); enum str = rc.str~"_ptr"; } enum tmp = proxy!lr1.str;
Comment #2 by yshuiv7 — 2018-08-25T15:54:51Z
The behavior of the compiler seems to be sensitive to pragma: ... // This is the second `gen` template gen(T: S*, S) { private alias rc = proxy!S; pragma(msg, is(typeof(rc.str))); // false //pragma(msg, __traits(allMembers, rc)); enum str = rc.str~"_ptr"; } Above version generate: package.d(19): Error: variable `package.gen!(lr1*, lr1).str` had semantic errors when compiling
Comment #3 by yshuiv7 — 2019-05-23T10:30:16Z
The behavior is changed since 2.069.2, as run.dlang.io shows: https://run.dlang.io/is/lOtIDw
Comment #4 by yshuiv7 — 2019-05-23T10:30:59Z
The behavior is changed since 2.069.2, as run.dlang.io shows: https://run.dlang.io/is/lOtIDw
Comment #5 by yshuiv7 — 2019-05-23T10:32:57Z
This code even triggers an "Error: unknown": https://run.dlang.io/is/ntQYrl
Comment #6 by robert.schadek — 2024-12-13T19:00:20Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19478 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB