From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2053D3858D20; Fri, 3 Feb 2023 10:08:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2053D3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675418891; bh=Aqf4KhYGbxpj+qyngk5I4CNCtRsDuLWCRfnJ/nszQG4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gCWBlhv3hfDsHN6sFxrxUxnSDe7lWFu7x9mjeVKUqZICqxKvFBItIJbT7Z1uDKYsL +cq2Mz3MVPGZaAAatfaUBKBZL9rJ/SKclQBaRjV784jyLpbXjPr2SIMPQsPdoaAy34 COIe1I8xv7V/AheBzwKc1GPLpp8BD6ECMqaedOK4= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/108645] Change in behavior, std::accumulate doesn't always work as expected in C++20 builds Date: Fri, 03 Feb 2023 10:08:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi 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: 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=3D108645 --- Comment #5 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #3) > In your example, all your strings fit in the SSO buffer inside the > std::string object, so the LHS has sufficient capacity for the result. Actually that's only true until the last step of the algorithm. On the last step (when appending "example" to "this_is_an_") neither the LHS nor the RHS has capacity for the result, so a reallocation is needed. But it's true that the RHS has nothing to steal at any step in the algorithm, so we append to = the LHS and let that reallocate itself if needed. > And > there's nothing to steal from the RHS anyway, as it doesn't own any > allocated memory.=