From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 14CBA3858C33; Wed, 24 Aug 2022 22:39:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 14CBA3858C33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from linux-libre.fsfla.org ([209.51.188.54]:46022 helo=free.home) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQz1p-00013m-09; Wed, 24 Aug 2022 18:39:17 -0400 Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 27OMd2De2639472 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 24 Aug 2022 19:39:04 -0300 From: Alexandre Oliva To: Jonathan Wakely via Gcc-patches Cc: whh8b@obs.cr, Jonathan Wakely , libstdc++@gcc.gnu.org Subject: Re: [PATCH] libstdc++: Optimize operator+(string/char*, string/char*) equally Organization: Free thinker, not speaking for the GNU Project References: <20220822181509.1032874-2-whh8b@obs.cr> <20220824061648.1119635-1-whh8b@obs.cr> <20220824061648.1119635-2-whh8b@obs.cr> Errors-To: aoliva@lxoliva.fsfla.org Date: Wed, 24 Aug 2022 19:39:02 -0300 In-Reply-To: (Jonathan Wakely via Gcc-patches's message of "Wed, 24 Aug 2022 15:24:11 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Aug 24, 2022, Jonathan Wakely via Gcc-patches wrote: > * include/bits/basic_string.h (operator+(const string&, > const char*)): > Remove naive implementation. > * include/bits/basic_string.tcc (operator+(const string&, > const char*)): > Add single-allocation implementation. ISTM this requires the following additional tweak: diff --git a/libstdc++-v3/src/c++11/string-inst.cc b/libstdc++-v3/src/c++11/string-inst.cc index bfae6d902a1dd..2ec0e9d85f947 100644 --- a/libstdc++-v3/src/c++11/string-inst.cc +++ b/libstdc++-v3/src/c++11/string-inst.cc @@ -58,6 +58,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template class basic_string; template S operator+(const C*, const S&); + template S operator+(const S&, const C*); template S operator+(C, const S&); template S operator+(const S&, const S&); Without this, I'm getting undefined references to this specialization in libstdc++.so, that I tracked down to a std::system_error ctor in cxx11-ios_failure.o. I got this while testing another patch that might be the reason why the template instantiation doesn't get inlined, but... we can't depend on its being inlined, can we? -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer Disinformation flourishes because many people care deeply about injustice but very few check the facts. Ask me about