March 06, 2019 [Issue 19720] New: const structs without explicit initializer are not usable in CTFE expressions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19720 Issue ID: 19720 Summary: const structs without explicit initializer are not usable in CTFE expressions Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: johannes.riecken@gmail.com Code: dmd -main -run -<<<'struct S {int i;}const S s;pragma(msg, s);' Expected output: S(0) Actual output: __stdin.d(1): Error: static variable s cannot be read at compile time __stdin.d(1): while evaluating pragma(msg, s) Note that initializing explicitly using a struct initializer literal gives the expected result: dmd -main -run -<<<'struct S {int i;}const S s={};pragma(msg, s);' S(0) -- |
Copyright © 1999-2021 by the D Language Foundation