From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 77FEC3858418; Tue, 11 Apr 2023 13:38:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77FEC3858418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681220305; bh=/WexZTgJCn25bum8w0zsxcQhfd+N75IKqQzvFtpwWCk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=yVSllbp8T37uLPyhQ+ef5BObAgYlKVUuclBUpPDTPbFagkjID86LK+nD5kH7lcnaY UYqu9gEUUTdr2Riv4WEavA3cGQhkDPfhfD9qaRsZpjb+HmXV6yy4Q0SCsHlXJdaBjG bt3MwIlbP9QEa+x36+P/3vRHQr2In6+vgHyB5Ub8= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109442] Dead local copy of std::vector not removed from function Date: Tue, 11 Apr 2023 13:38:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109442 --- Comment #3 from Jonathan Wakely --- Ah, maybe the problem is that the library code manually elides destroying t= he elements, precisely because it's a no-op. So we don't actually destroy the elements, which means the compiler might think they're still initialized an= d so could be inspected. If the library explicitly does vec[i].~T() for every i then would that help? The compiler would know there are no valid elements in the storage, and so nothing operator delete could inspect. We could continue to elide destroying the elements when !defined __OPTIMIZE= __ so that we don't run a loop that does nothing, but with optimization enabled rely on the compiler to remove that loop.=