[Issue 14931] switch doesn't work with any pointers
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Tue Aug 18 07:57:01 PDT 2015
    
    
  
https://issues.dlang.org/show_bug.cgi?id=14931
Andrei Alexandrescu <andrei at erdani.com> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86                         |All
                 OS|Mac OS X                    |All
--- Comment #1 from Andrei Alexandrescu <andrei at erdani.com> ---
Consider:
void fun(T)() {}
alias Ptr = void function() pure nothrow @nogc @safe;
void main(string[] argv) {
    enum a = &fun!int;
    static immutable Ptr b = &fun!double;
    static assert(a != b);
    Ptr p;
    switch (p)
    {
        case a: break;
        case b: break;
    }
}
The first three lines in main() clarify that pointers to functions can be
evaluated and compared during compilation. Yet the switch statement does not
work.
This applies to general pointers - switch does not work with any pointers, yet
it should work because pointers are comparable and there exist constant
pointers.
--
    
    
More information about the Digitalmars-d-bugs
mailing list