On 9/21/2013 11:03 AM, Maxim Fomin wrote:
For example, I was pissed off two days ago when
git-head dmd rejected to compile large code base due to some 'enum overflow'
error. Being watching bugzilla and github for two years, that change was neither
expected nor clear for me.

Enum members with no initializer are defined to be set to the previous enum member's value + 1. This, of course, can overflow if the previous value is the max value for the type. For example,

enum E {
    A = int.max,
    B
}

C:\cbx\mars>dmd test
test.d(3): Error: enum member test.E.B overflow of enum value cast(E)2147483647

This change was made because the behavior of ignoring the overflow was listed as a bug.

Since you said it was unclear, how could this be made clear?

------------------------------------
As C code:

enum E {
    A = 2147483647,
    B
};

and gcc reports:

test.c:4: error: overflow in enumeration values

Reply via email to