[Issue 22256] New: casting int from struct member to enum fails at compile time

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 30 22:53:56 UTC 2021


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

          Issue ID: 22256
           Summary: casting int from struct member to enum fails at
                    compile time
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dkorpel at live.nl

```
enum E {
    e
}
struct S {
    int s;
}
enum E e1 = cast(E) S(0).s;
```

onlineapp.d(7,23): Error: cannot implicitly convert expression `0` of type
`int` to `E`

This should compile, but dmd for some reason wants to convert `0` to `E` in the
constructor of `S`.

--


More information about the Digitalmars-d-bugs mailing list