On Saturday, 21 September 2013 at 18:55:46 UTC, Walter Bright
wrote:
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
Thanks, that is clear. Unfortunately, I cannot say that the
explanation improves my attidute to the language - dmd still
breaks too often code and some significant features (like AAs,
scope, shared) are at risk to be seriously changed which is a
serious problem to the user.