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.
Comment #1 by henning — 2013-07-29T12:52:16Z
Comment #2 by github-bugzilla — 2013-07-31T19:23:19Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/1393836e36f80dfedfdc388cb0ac6b7aed08307e fix issue 2407 - function pointer as an enum's base type doesn't work https://github.com/D-Programming-Language/dmd/commit/24042483d70805d8ffeed12046707a6b0008b9f6 Merge pull request #2418 from hpohl/2407 fix issue 2407 - function pointer as an enum's base type doesn't work