digitalmars.D.bugs - [Issue 16081] New: CTFE mistakes &arr for arr in cast
- via Digitalmars-d-bugs (34/34) May 26 2016 https://issues.dlang.org/show_bug.cgi?id=16081
https://issues.dlang.org/show_bug.cgi?id=16081 Issue ID: 16081 Summary: CTFE mistakes &arr for arr in cast Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: ag0aep6g gmail.com Encountered by Era Scarecrow in D.learn: http://forum.dlang.org/post/mzzpcdzuovajqygueqwc forum.dlang.org ---- 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. --
May 26 2016