[Issue 16081] New: CTFE mistakes &arr for arr in cast
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu May 26 15:09:08 PDT 2016
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 at puremagic.com
Reporter: ag0aep6g at 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.
--
More information about the Digitalmars-d-bugs
mailing list