[Issue 13247] switch doesn't work with pointers to functions. Also casting pointers to functions to integers doesn't work during compilation.

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Aug 4 11:02:46 PDT 2014


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

--- Comment #3 from Andrei Alexandrescu <andrei at erdani.com> ---
(In reply to yebblies from comment #2)
> While you can do some things with a function pointer at compile time, you
> _cannot_ convert it to an integer.

Can you elaborate? Couldn't the linker just fix up the address as it does for
calls?

> I'm not sure why you would expect switch to work on function pointers.

In std.variant, sometimes it's better to just switch on the tag (which is a
pointer to function) instead of making an indirect call through it.

--


More information about the Digitalmars-d-bugs mailing list