From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 664733858D28; Sun, 19 Dec 2021 03:44:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 664733858D28 From: "dprokoptsev at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/103755] {has,use}_facet() and iostream constructor performance Date: Sun, 19 Dec 2021 03:44:50 +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: dprokoptsev at gmail dot com 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 03:44:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103755 --- Comment #6 from Dmitry Prokoptsev --- That would also work, I suppose (it even outperforms my original approach b= y a tiny bit -- 33 ns for v2 vs 36 for my original implementation). 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 al= ign with the static assert message? 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 ld: /home/av/prgs/gcc/debug/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc+= +.so: undefined reference to `std::num_get > > const* std::__try_use_facet > > >(std::locale const&)' Suggest explicitly instantiating __try_use_facet where has_facet() and use_facet() is instantiated. See attached fix for build problems I discovered.=