|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
D.gnu - enum is int or uint?
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
added to DStress as: http://svn.kuehne.cn/dstress/run/enum_09.d shinichiro.h schrieb am Freitag, 12. November 2004 15:32: Nov 14 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. Nov 12 2004
|