www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21642] New: [REG 2.084] hashOf will fail to compile for some

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

          Issue ID: 21642
           Summary: [REG 2.084] hashOf will fail to compile for some
                    structs/unions that recursively contain shared enums
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: n8sh.secondary hotmail.com

The following code compiles with DMD 2.067.1 to 2.083.1 but fails to compile on
2.084.1:

---
void main()
{
    enum C : char { _ = 1, }
    union U { C c; void[0] _; }
    shared union V { U u; }
    cast(void) hashOf(V.init);
}
---

The underlying issue is a problem with the CTFE path for getting the byte
representation of shared enum members. The following code has never compiled
but that only became a problem after 2.084:

---
void main()
{
    import core.internal.convert : toUbyte;
    enum C : char { _ = 1, }
    shared C c;
    cast(void) toUbyte(c);
}
---

--
Feb 17 2021