[Issue 14950] New: Setting enum value to the last member of another enum causes int overflow error

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Aug 22 18:09:14 PDT 2015


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 at puremagic.com
          Reporter: initrd.gz at 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."]

--


More information about the Digitalmars-d-bugs mailing list