From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4B0923858C2C; Thu, 24 Aug 2023 07:36:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B0923858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692862565; bh=U8TlwQPAWPm9pzL91zxBUW+HXVtUtZZJooA+N/I+YCg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wizIQS1RxOKfJ71XvejaEftjlS2V9vW8COoDoNYWghyZDHmLGHqe4zTM86/Kcgx/P /MeFwesHtNvJnBjm0kquqPeg1S1c44MEhOfWZYzGcOErvDyIXBNxjLyxh7ceRcm7Wt caS7CWyAjWi4TmFgRjVanLsyP4TntvuoPuG7nfNY= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111123] Warning about "used uninitialized" member shown or hidden randomly Date: Thu, 24 Aug 2023 07:36:04 +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: 13.2.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc blocked 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111123 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mpolacek at gcc dot gnu.org Blocks| |24639 --- Comment #4 from Richard Biener --- The interesting thing is that enabling the middle-end diagnostic to trigger shows we emit duplicate diagnostics: struct Camera { float clip_area; float border =3D 10.f; [[gnu::noinline]] Camera() : clip_area(border) { } }; Camera foo() { Camera c; return c; } emits t.C: In constructor 'Camera::Camera()': t.C:4:44: warning: member 'Camera::border' is used uninitialized [-Wuninitialized] 4 | [[gnu::noinline]] Camera() : clip_area(border) { } | ^~~~~~ t.C: In constructor 'Camera::Camera()': t.C:4:44: warning: '*this.Camera::border' is used uninitialized [-Wuninitialize] 4 | [[gnu::noinline]] Camera() : clip_area(border) { } | ^~~~~~ the first is from the C++ FE find_uninit_fields diagnostic which for some reason doesn't work for the testcase in the description, possibly the initializer list(?) isn't handled? The early uninit IL is : MEM[(struct __as_base &)this_6(D)] =3D{v} {CLOBBER}; _1 =3D &this_6(D)->clip_area; std::allocator::allocator (&D.26049); _2 =3D this_6(D)->border; D.26047[0].x =3D _2; _3 =3D this_6(D)->border; D.26047[0].y =3D _3; D.27007._M_array =3D &D.26047; D.27007._M_len =3D 1; std::vector::vector (_1, D.27007, &D.26049); the call to std::allocator::allocator is thought to clobber *this and thus possibly initialize 'border' here. I'm testing a middle-end fix here - Marek, can you see whether it's possible to detect this in the frontend? The middle-end will require optimization. The duplicate diagnostic might also be interesting to look at, but that might already be reported separately? Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D24639 [Bug 24639] [meta-bug] bug to track all Wuninitialized issues=