Bug 21687 – Confusing error message for CTFE pointer in static initializer

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-03-07T18:12:17Z
Last change time
2021-04-09T10:48:56Z
Keywords
diagnostic, pull
Assigned to
No Owner
Creator
Paul Backus

Comments

Comment #0 by snarwin+bugzilla — 2021-03-07T18:12:17Z
Example program: --- auto p = new int; --- With DMD 2.095.0, attempting to compile the above program produces the following error message: --- Error: cannot use non-constant CTFE pointer in an initializer `&[0][0]` --- The initializer expression appears in the source code as `new int`, but is printed as `&[0][0]`.
Comment #1 by razvan.nitu1305 — 2021-03-08T10:55:34Z
This is actually a regression. Version 2.065.0 prints: Error: Cannot interpret new int at compile time whereas, starting from 2.066.0: Error: cannot use non-constant CTFE pointer in an initializer `&[0][0]` which seems to be a spill from the compiler lowering.
Comment #2 by johan_forsberg_86 — 2021-03-18T13:12:33Z
I have a fix for this, it's related to ctfeInterpret
Comment #3 by dlang-bot — 2021-03-18T18:40:28Z
@Imperatorn created dlang/dmd pull request #12287 "Fix issue 21687 - Confusing error message for CTFE" fixing this issue: - Fix issue 21687 - Confusing error message for CTFE https://github.com/dlang/dmd/pull/12287
Comment #4 by dlang-bot — 2021-03-19T05:58:52Z
dlang/dmd pull request #12287 "Fix issue 21687 - Confusing error message for CTFE" was merged into stable: - 68c96aae0642a43715c4c67c76cf62cf1ac5f7f6 by Johan Forsberg: Fix issue 21687 - Confusing error message for CTFE https://github.com/dlang/dmd/pull/12287
Comment #5 by dlang-bot — 2021-04-09T10:48:56Z
dlang/dmd pull request #12408 "Merge stable into master" was merged into master: - 75fe50f497dceeaf49651259df8c52d3318f037e by Imperatorn: Fix issue 21687 - Confusing error message for CTFE (#12287) Co-authored-by: Johan Forsberg <[email protected]> https://github.com/dlang/dmd/pull/12408