From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 49DB5386F440; Fri, 10 May 2024 16:12:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49DB5386F440 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715357538; bh=haKp6Lag18Q6HATfZUxVBp5N2iAa6YgIuXa5AwUfIsQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NduTxQA34k14JJdID2lcBnbonNxUBjtXLKo+6Ff7yIfS+xSAGlPtRivaODgYY1tie DZnnCcHQCV35oohSOr3NcyX/jyspw3Bsi6a3iqp+TFDKk5z4eaAO6bdqS8NeS+GOrz GMdiS1E3QcyqpoUJccpEQ+f2oayA1+WRFAj8XVfY= From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/115037] Unused std::vector is not optimized away. Date: Fri, 10 May 2024 16:12:17 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at gcc dot gnu.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: cc 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=3D115037 Jan Hubicka changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at redhat dot com, | |jwakely at redhat dot com --- Comment #2 from Jan Hubicka --- I tried to look for duplicates, but did not find one. However I think the first problem is that we do not optimize away the store= of 1 to vector while clang does. I think this is because we do not believe we= can trust that delete operator is safe? We get: void test () { int * test$D25839$_M_impl$D25146$_M_start; struct vector test; int * _61; [local count: 1073741824]: _61 =3D operator new (4); [local count: 1063439392]: *_61 =3D 1; operator delete (_61, 4); test =3D{v} {CLOBBER}; test =3D{v} {CLOBBER(eol)}; return; [count: 0]: : test =3D{v} {CLOBBER}; resx 2 } If we can not trust fact that operator delete is good, perhaps we can arran= ge explicit clobber before calling it? I think it is up to std::vector to deci= de what it will do with the stored array so in this case even instane oprator delete has no right to expect that the data in vector will be sane :)=