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

            Bug ID: 111123
           Summary: Warning about "used uninitialized" member shown or
                    hidden randomly
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: agriff at tin dot it
  Target Milestone: ---

This code should warning (with -Wall) about the use of `border` that is
uninitialized

    #include <stdio.h>
    #include <vector>

    struct Camera {
        struct P2d {
            float x, y;
        };
        std::vector<P2d> clip_area;
        float border = 10.f;
        int z = 3;
        Camera() : clip_area({{border, border},
                              {1-border, border},
                              {1-border, 1-border},
                              {border, 1-border}})
        { }
    };

    int main() {
        Camera c;
        printf("%.18g\n", c.clip_area[0].x);
    }

However does so only if member `z` is present; commenting out the line `int z =
3;` silences the warning.

This show/hide of the warning happens also pseudo-randomly in other cases
(while I was trying to get the minimum code showing the problem I found many
cases in which removing even an executable statement in the body of a method
triggered the behavior change).

Reply via email to