www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22256] New: casting int from struct member to enum fails at

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 puremagic.com
          Reporter: dkorpel 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`.

--
Aug 30