From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 98EA23858401; Mon, 24 Jul 2023 14:17:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98EA23858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690208268; bh=NiaZCyerDjjPESvJVVXBKh6XMN3530YnxfEOpwyI29I=; h=From:To:Subject:Date:From; b=avcg7hKB4x8rvvT4X9dnnoDU8yldtGfipSCWecqpfJgKBTD3oG/XGTfX6ef3mfb4Q 7HlEFHNN/6IC2LC/vYwnW5Z+wiY3EF5duQ4CXXa9RkG36+Q3P3jXKaKARS/5ex6uCQ GAQ8oU7KD3PC9TWYDsUkb2g+ProfKCuQCUtL3Ar8= From: "barry.revzin at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110793] New: regression in optimizing unused string Date: Mon, 24 Jul 2023 14:17:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: barry.revzin at gmail dot com 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D110793 Bug ID: 110793 Summary: regression in optimizing unused string Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- Consider this reduced, silly-looking example: #include inline int zero(std::string const& =3D {}) { return 0; } int main() { return zero(); } In several versions of gcc (12.2, 11.4, 10.5), this simply compiles to: main: xor eax, eax ret But in 13.1 (C++17, but not C++20), we get: main: sub rsp, 40 lea rax, [rsp+16] mov rdi, rsp mov BYTE PTR [rsp+16], 0 mov QWORD PTR [rsp], rax mov QWORD PTR [rsp+8], 0 call std::__cxx11::basic_string, std::allocator >::_M_dispose() xor eax, eax add rsp, 40 ret Notably, 13.1 C++20 and C++23 also compiles to just xor.=20 I'm not sure if this is a language or library issue, so tagging it language= for now.=