D.gnu - enum is int or uint?
- shinichiro.h (16/16) Nov 03 2004 Hi,
- Lionello Lunesu (4/4) Nov 11 2004 Seems strange to me that you're allowed to do "operator -" on an enum at...
- shinichiro.h (9/12) Nov 12 2004 I think enum of C and D is just one of the integral type and IMHO my
- Thomas =?UTF-8?B?S8O8aG5l?= (3/11) Nov 14 2004 added to DStress as:
Hi, When I compile the following code with DMD, it does not fail. But with GDC, it fails: int main() { enum E { A, B }; E e = -E.B; assert(e < 0); return 0; } That's because DMD treats enum as int but GDC may treat as uint. The language specification of D says the behavior of DMD is correct. The EnumBaseType is the underlying type of the enum. It must be an integral type. If omitted, it defaults to int. http://digitalmars.com/d/enum.html ------------------ shinichiro.h
Nov 03 2004
Seems strange to me that you're allowed to do "operator -" on an enum at all. The result is not a valid value for enum E. Lio.
Nov 11 2004
Seems strange to me that you're allowed to do "operator -" on an enum at all. The result is not a valid value for enum E.I think enum of C and D is just one of the integral type and IMHO my code is legal. But there is not the essence of the problem. So I refined my code. int main() { enum E { A = -1 }; E e = E.A; assert(e < 0); return 0; }
Nov 12 2004
added to DStress as: http://svn.kuehne.cn/dstress/run/enum_09.d shinichiro.h schrieb am Freitag, 12. November 2004 15:32:So I refined my code. int main() { enum E { A = -1 }; E e = E.A; assert(e < 0); return 0; }
Nov 14 2004