From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 49A6A3858D1E; Thu, 22 Dec 2022 13:42:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49A6A3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671716525; bh=JtirjxeYEtlGOa8d2CN/EEN4BNhKxZ8y3sBMymHHV8Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=V2QVSG7F/FOTcqS6dYUNg2qlrQOP+CVTyaZ5zFczDtcGCy0TNKfbk90hzX14RQD3R CPCi0DdvA9fMDi1UJWbSgeVgj/3DPEQhVjJyqpjgYnOpv4TwRhGCmlQbh4depn3kbS GJlCnkp8JFqngjndbBJWsGwsOrapsvVtUtM4/4m4= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107138] [12/13 regression] std::variant triggers false-positive 'may be used uninitialized' warning Date: Thu, 22 Dec 2022 13:42:02 +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: 12.2.0 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords cf_reconfirmed_on everconfirmed bug_status priority 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=3D107138 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Last reconfirmed| |2022-12-22 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Priority|P3 |P2 --- Comment #11 from Richard Biener --- Confirmed. We're diagnosing the read # VUSE <.MEM_106> _60 =3D MEM[(const struct basic_string *)&D.48280]._M_string_length; which happens conditional after the lifetime of D.48280 starts: MEM[(struct __as_base &)&D.48280] =3D{v} {CLOBBER}; MEM[(union _Variadic_union *)&D.48280] =3D{v} {CLOBBER}; MEM[(union _Variadic_union *)&D.48280] =3D{v} {CLOBBER}; MEM[(struct _Uninitialized *)&D.48280] =3D{v} {CLOBBER}; _128 =3D (void *) ivtmp.494_2; _19 =3D MEM[(const type &)_128]; MEM[(struct _Uninitialized *)&D.48280]._M_storage =3D _19; MEM[(struct _Variant_storage *)&D.48280]._M_index =3D 2; ... the condition chains is [local count: 668941184]: MEM[(struct _Variant_storage *)_35]._M_index =3D 255; _45 =3D D.48280.D.48091.D.47570.D.47488.D.47356.D.47242.D.47146._M_index; _46 =3D (signed char) _45; _47 =3D (long unsigned int) _46; if (_47 > 4) goto ; [16.67%] else goto ; [83.33%] [local count: 557450988]: switch (_45) [20.00%], case 1: [20.00%], case 2: [20.00%], case 3: [20.00%], case 4: [20.00%]> [local count: 111490196]: : _57 =3D &MEM[(struct basic_string *)_35].D.36033._M_local_buf; MEM[(struct _Alloc_hider *)_35]._M_p =3D _57; _58 =3D MEM[(const struct basic_string *)&D.48280]._M_dataplus._M_p; if (&MEM[(const struct basic_string *)&D.48280].D.36033._M_local_buf =3D=3D= _58) goto ; [30.00%] else goto ; [70.00%] [local count: 33447058]: _60 =3D MEM[(const struct basic_string *)&D.48280]._M_string_length; in this case we have other stores possibly clobbering the _M_index store so we fail to statically optimize these branches (from the =3D 2 initializer which should be still there?).=