D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6603 - [CTFE] Can't call through a manifest constant function pointer
Summary: [CTFE] Can't call through a manifest constant function pointer
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-05 00:31 UTC by Don
Modified: 2015-06-09 05:10 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2011-09-05 00:31:37 UTC
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.