Bug 23492 – Enum types with float base don't match the spec

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-11-17T11:05:54Z
Last change time
2023-01-30T17:02:28Z
Assigned to
No Owner
Creator
Ate Eskola

Comments

Comment #0 by Ajieskola — 2022-11-17T11:05:54Z
With dmd version 2.100.1, rdmd --eval 'enum E : float{x, y} writeln(cast(float)E.x, " ", cast(float)E.y)' prints "0, 1". However, the spec states (17.2) that if a first member of enum type is not specified, it should be the .init value of the base type. Thus this example should print "nan nan". Side note: the spec also states that if an unspecified member is equal to the member before it, the compiler should error. Technically that part is not violated by printing "nan nan" though because NaNs are not equal to themselves. The compiler does not currently error if the first member is explicitly set as nan so it behaves according to spec in that regard.
Comment #1 by nick — 2023-01-30T17:02:28Z
*** This issue has been marked as a duplicate of issue 18578 ***