www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21711] New: Concatenating a function pointer with a string

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 puremagic.com
          Reporter: thomas.bockman 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)

--
Mar 13