www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14950] New: Setting enum value to the last member of another

https://issues.dlang.org/show_bug.cgi?id=14950

          Issue ID: 14950
           Summary: Setting enum value to the last member of another enum
                    causes int overflow error
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: initrd.gz gmail.com

I encountered this when writing interfaces for a C library.

Code sample:

    enum A {
        start,
        end
    }

    enum B {
        start = A.end,
        end
    }

 rdmd -main ./test.d 
./test.d(9): Error: enum member test.B.end initialization with (B.start + 1) causes overflow for type 'int' Failed: ["dmd", "-main", "-v", "-o-", "./test.d", "-I."] --
Aug 22 2015