public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "agriff at tin dot it" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/111123] New: Warning about "used uninitialized" member shown or hidden randomly
Date: Wed, 23 Aug 2023 19:57:02 +0000	[thread overview]
Message-ID: <bug-111123-4@http.gcc.gnu.org/bugzilla/> (raw)

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	other threads:[~2023-08-23 19:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-23 19:57 agriff at tin dot it [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-111123-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).