Bug 2407 – function pointer as an enum's base type doesn't work
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2008-10-09T09:03:00Z
Last change time
2015-06-09T01:21:35Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
qniol
Comments
Comment #0 by qniol — 2008-10-09T09:03:43Z
Take a look at this snippet:
1. void foo() {}
2. void bar() {}
3.
4. enum Enum : void function() {
5. FOO = &foo,
6. BAR = &bar
7. }
8.
9. int main() {return 0;}
error message:
enum.d(6): Error: Integer constant expression expected instead of (& bar) < (& foo)
enum.d(6): Error: Integer constant expression expected instead of (& bar) > (& foo)
However, this one works fine:
1. void foo() {}
2. void bar() {}
3.
4. enum Enum : void function() {
5. FOO = &foo
6. //BAR = &bar
7. }
8.
9. int main() {return 0;}
Docs say that 'Type' can be the base of enum, where 'Type's' definition is in "Declarations" of 2.0 and includes function pointer, so I guess the first case is the bug.