www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23064] New: wrong code generated for bitfield assignment to ?:

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

          Issue ID: 23064
           Summary: wrong code generated for bitfield assignment to ?:
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

The generated code is as if a.x and a.y were regular fields instead of
bitfields.

struct A { int x: 3; int y: 5; } a;

struct A test(int val, int choice, struct A a)
{
    (choice ? a.x : a.y) = val;
    return a;
}

Affects D and ImportC.

--
Apr 27 2022