www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2407] New: function pointer as an enum's base type doesn't work

http://d.puremagic.com/issues/show_bug.cgi?id=2407

           Summary: function pointer as an enum's base type doesn't work
           Product: D
           Version: 2.014
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: marcin.wcislo gmail.com


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.


-- 
Oct 09 2008