Bug 16081 – CTFE mistakes &arr for arr in cast

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-05-26T22:09:08Z
Last change time
2024-12-13T18:48:05Z
Assigned to
No Owner
Creator
ag0aep6g
Moved to GitHub: dmd#17757 →

Comments

Comment #0 by ag0aep6g — 2016-05-26T22:09:08Z
Encountered by Era Scarecrow in D.learn: http://forum.dlang.org/post/[email protected] ---- size_t f() { size_t[] arr = [13]; return *(cast(size_t*) &arr); } void main() { import std.stdio; enum ct = f(); auto rt = f(); writeln(ct, " ", rt); } ---- Prints: "13 1". The expected value is 1 for both. A "not supported" error during CTFE would also be acceptable, as happens when &arr is assigned to a variable first. Looks like CTFE mistakes &arr for arr here.
Comment #1 by dfj1esp02 — 2016-05-27T12:28:00Z
Also: size_t f() { int[] arr = [13]; return *(cast(size_t*) &arr); } Error: reinterpreting cast from int[] to ulong* is not supported in CTFE
Comment #2 by robert.schadek — 2024-12-13T18:48:05Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17757 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB