[Issue 23492] New: Enum types with float base don't match the spec

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 17 11:05:54 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23492

          Issue ID: 23492
           Summary: Enum types with float base don't match the spec
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: Ajieskola at gmail.com

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.

--


More information about the Digitalmars-d-bugs mailing list