Comment #0 by thomas.bockman — 2021-03-14T04:08:57Z
Here's a weird bug (this works since 2.066.0):
unittest {
assert(is(typeof(cast(typeof({})) 91)
== void function() pure @safe nothrow @nogc));
// This definitely should not pass, but does:
assert((cast(typeof({})) 91) ~ "" == "[");
}
It becomes a compile-time error, as it should be, if the function pointer expression is replaced with a variable of the same type and value.
(Reduced from an obfuscation puzzle posted on the forums:
https://forum.dlang.org/post/[email protected])
Comment #1 by ag0aep6g — 2021-03-14T11:30:25Z
The issue seems to be that constant folding ignores the type. Test case without a function pointer:
----
void main()
{
immutable void* x = cast(void*) 91;
string s = x ~ ""; /* accepted; should be rejected */
}
----
Comment #2 by robert.schadek — 2024-12-13T19:15:08Z