From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 76AE93858408; Sun, 19 Dec 2021 13:04:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76AE93858408 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/103755] {has,use}_facet() and iostream constructor performance Date: Sun, 19 Dec 2021 13:04:33 +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: 11.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Dec 2021 13:04:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103755 --- Comment #7 from Jonathan Wakely --- (In reply to Dmitry Prokoptsev from comment #6) > That would also work, I suppose (it even outperforms my original approach= by > a tiny bit -- 33 ns for v2 vs 36 for my original implementation). >=20 > There are a few build errors in the alternative implementations, however: > is_convertible::value is false, as it tries to > downcast the facet -- did you mean is_base_of<>, which would also better > align with the static assert message? Yes, I've already changed it to use that in my local branch. > Also, despite the always_inline attribute of __try_use_facet, my attempts= to > build the library with -O0 -ggdb and link my benchmark yielded a bunch of > errors like=20 >=20 > ld: > /home/av/prgs/gcc/debug/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstd= c++. > so: undefined reference to `std::num_get std::istreambuf_iterator > > const* > std::__try_use_facet std::char_traits > > >(std::locale const&)' Yes, that's what happens for the debug libs built with --enable-libstdcxx-d= ebug=20 > Suggest explicitly instantiating __try_use_facet where has_facet() and > use_facet() is instantiated. Yes, I wanted to avoid that :-( > See attached fix for build problems I discovered. Thanks, I'll compare it with the fixes I've already got locally and finish retesting.=