www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21785] New: Cannot declare variable of opaque enum with base

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

          Issue ID: 21785
           Summary: Cannot declare variable of opaque enum with base type
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: moonlightsentinel disroot.org

The following code doesn't compile unless `var` is void-initialized:

--------------------------------------
enum Xobj : void*;

void main()
{
    Xobj var;
}
--------------------------------------

Error: enum enum_init.Xobj forward reference of Xobj.init

There is no forward reference involved and `var` can just be initialized by
`void.init`.

--
Mar 30 2021