Bug 6603 – [CTFE] Can't call through a manifest constant function pointer

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-09-05T00:31:00Z
Last change time
2015-06-09T05:10:45Z
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2011-09-05T00:31:37Z
This CTFE code works: --- int f3(int a) { return a+5; } int foo() { auto fe = &f3; assert(fe(6) == 11); return 3; } static assert(foo()==3); --- But this is rejected: --- int f3(int a) { return a+5; } enum fe = &f3; static assert(fe(6)==11); --- test.d(5): Error: cannot evaluate (*& f3)(6) at compile time The difference is, that in the first case, fe is a variable. In the second case, it's a constant.
Comment #1 by bugzilla — 2011-11-02T13:06:44Z