www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24045] New: Compiler fails to recognize overlapping Union

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

          Issue ID: 24045
           Summary: Compiler fails to recognize overlapping Union elements
                    in CTFE
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: puneet coverify.org

enum bool bar = foo(42);

bool foo(ubyte c) {
  union U {
    uint a;
    ubyte[4] b;
  }
  U u;
  u.b[0] = c;
  assert (u.a == c, "This should never happen");
  return true;
}

--
Jul 13 2023