public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111123] New: Warning about "used uninitialized" member shown or hidden randomly
@ 2023-08-23 19:57 agriff at tin dot it
  2023-08-23 20:12 ` [Bug c++/111123] " agriff at tin dot it
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: agriff at tin dot it @ 2023-08-23 19:57 UTC (permalink / raw)
  To: gcc-bugs

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).

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-08-24 13:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-23 19:57 [Bug c++/111123] New: Warning about "used uninitialized" member shown or hidden randomly agriff at tin dot it
2023-08-23 20:12 ` [Bug c++/111123] " agriff at tin dot it
2023-08-24  6:52 ` rguenth at gcc dot gnu.org
2023-08-24  7:14 ` rguenth at gcc dot gnu.org
2023-08-24  7:36 ` rguenth at gcc dot gnu.org
2023-08-24 13:11 ` cvs-commit at gcc dot gnu.org
2023-08-24 13:13 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).