https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127944

            Bug ID: 127944
           Summary: Unintialized member copy not diagnosed in constant
                    expressioin
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: namark at disroot dot org
  Target Milestone: ---

I recently started running all my unit tests with conteval to detect UB, and
noticed that gcc does not diagnose this case:

[]() consteval
{
    struct A { int m; };
    A x;
    A y = x;
}();

clang does. Not sure if the diagnostic is required by the standard, but would
be nice to have. My actual case involved a partially initialized array member:

    struct A { int m[2]; };
    A x;
    x.m[0] = 1;
    A y = x;

Tested in c++20 mode with versions 11.5.0, 13.10, and 16.0 locally and trunk on
godbolt.

Reply via email to