From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8B7983858C3A; Thu, 6 Jan 2022 14:30:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B7983858C3A From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/103923] is_invocable inexplicably fails Date: Thu, 06 Jan 2022 14:30:30 +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: normal 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: cc 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: Thu, 06 Jan 2022 14:30:30 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103923 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fdumont at gcc dot gnu.org --- Comment #7 from Jonathan Wakely --- Ugh, this is a big can of worms. The current code is wrong, because __cache_default can silently = give the wrong answer, and cause ODR violations. But if we change __cache_default to give the right answer, we break existing tests: FAIL: 23_containers/unordered_map/48101_neg.cc (test for errors, line 27) FAIL: 23_containers/unordered_set/85965.cc (test for excess errors) We have tests that depend on NOT checking the hash function until all types= are complete. But that means it is impossible for __cache_default to do the rig= ht thing, because it requires completeness. The reason that __cache_default checks the hash function is to see whether = it throws or not. The code comments say: // Mandatory to have erase not throwing. __is_nothrow_invocable>>; and elsewhere: // Getting a bucket index from a node shall not throw because it is u= sed // in methods (erase, swap...) that shall not throw. Need a complete // type to check this, so do it in the destructor not at class scope. static_assert(noexcept(declval() ._M_bucket_index(declval(= ), (std::size_t)0)), "Cache the hash code or qualify your functors involved" " in hash code and bucket index computation with noexcept"); But this is nonsense. erase is not noexcept. [unord.req.except] specifically says "erase(k) does not throw an exception unless that exception is thrown = by the container=E2=80=99s Hash or Pred object (if any)". So why are we doing all this work (and causing bugs) to avoid throwing in erase, when we are allowed to throw in erase?! swap isn't allowed to call a throwing hash function, which seems to be a problem because we use _M_update_bbegin() in swap, but maybe we can do that another way that doesn= 't require calling _M_bucket_index. I'm not sure how we can change the definition of __cache_default now, witho= ut causing ABI breaks. But the current caching policy just seems wrong.=