From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6B0393851C1D; Sun, 3 May 2020 13:28:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B0393851C1D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588512528; bh=+8HS1ZLCFR9iu/zgyta0AmY9gzmMuxvEGXd4Voh4ESE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bcOU3Se3MKT68EkkxXAolttnrW6pMjHuinA/tZvbnPq95M7mB9a7gaP4QR9prHYy0 ZB5xeYHIjXsGZ6O3lp9/GE1o/yqTilSxgyy5xfa0BPAkxwmOWQoMNM9BNUx2zqmq6o Rz5ROeaD734ZDO529Pjdob3ccYDum5Bb0eU8aYwc= From: "bug-apl at gnu dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94905] Bogus warning -Werror=maybe-uninitialized Date: Sun, 03 May 2020 13:28:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 9.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bug-apl at gnu dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 May 2020 13:28:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94905 --- Comment #2 from Dr. J=C3=BCrgen Sauermann --- I checked different g++ versions; the problem occurs in versions 9, 10, and= 11 of g++ but not in version 8. I tried to shrink the code to the bare minimum but if I do so then the warn= ing is no longer emitted. I noticed that the warning has become more verbose in g++ version 11. Before version 11 the warning said (one example of many): Shape.hh:133:18: error: =E2=80=98shape_Z.Shape::rho[axis]=E2=80=99 may be u= sed uninitialized in this function [-Werror=3Dmaybe-uninitialized] if (rho[r]) { volume /=3D rho[r]; rho[r] =3D sh; volume *=3D rho[r]; } ~~~~~^ In version g++ 11 it now says: Shape.hh: In member function =E2=80=98virtual Token Bif_F12_FORMAT::eval_B(= Value_P)=E2=80=99: Shape.hh:133:18: error: =E2=80=98shape_Z.Shape::rho[]=E2=80=99 may= be used uninitialized in this function [-Werror=3Dmaybe-uninitialized] 133 | if (rho[r]) { volume /=3D rho[r]; rho[r] =3D sh; volume= *=3D rho[r]; } | ~~~~~^ The in shape_Z.Shape::rho[] above is the function argume= nt 'axis' of the function set_shape_item(axis, length) inside which the warnin= g is being issued. This suggests that the warning is issued whenever the compiler is unable to statically determine if some function argument (the vector index 'axiss' in this case) is inside or outside the initialized region of a vector. This seems to be overly picky; I would normally assume that the data member= s of a class are always initialized. If not then the constructor and not any mem= ber function should emit a warning. Thanks for your attention and for gcc/g++ J=C3=BCrgen Sauermann=