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