[Issue 21711] New: Concatenating a function pointer with a string should be an error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 14 04:08:57 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21711

          Issue ID: 21711
           Summary: Concatenating a function pointer with a string should
                    be an error
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: thomas.bockman at gmail.com

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/vijyjoncoozwqzrvkhat@forum.dlang.org)

--


More information about the Digitalmars-d-bugs mailing list