From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1A03F3858D1E; Tue, 2 May 2023 19:22:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A03F3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683055336; bh=O5jfxuEA1Kl7li33wi1W7ypK0PriSrgOshpf5ut2mJM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sWzYmMvaZd47rBhxcVOkMMpQUvHxoc6CZxtxlMhBt3dg+r1AbGx+nTWRBCDOIbnHZ EYI84s2/pzRkdd2120UwL1WJrIN0IJOgBbkWLuPodA2oUMkU4aELahreIcIgPk9Nai xKlxxbvYgxfcDUdb47CHtqfCXE+JjPTUVmGrRWas= From: "mpolacek at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109680] [13/14 Regression] is_convertible incorrectly true Date: Tue, 02 May 2023 19:22:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mpolacek at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.2 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=3D109680 --- Comment #7 from Marek Polacek --- Ah, I think I see what's going on here. Once again, the problem is that th= is assert no longer passes: #include static_assert (!std::is_convertible_v , ""); std::is_convertible does To test() { return std::declval(); } here, From is 'int () const'. std::declval is defined as: template typename std::add_rvalue_reference::type declval() noexcept; Now, std::add_rvalue_reference is defined as "If T is a function type that = has no cv- or ref- qualifier or an object type, provides a member typedef type which is T&&, otherwise type is T." In our case, T is cv-qualified, so the result is T, so we end up with int () const declval() noexcept; which is invalid. In other words: using T =3D int () const; T fn1(); // bad, fn returning a fn T& fn2(); // bad, cannot declare reference to qualified function type T* fn3(); // bad, cannot declare pointer to qualified function type using U =3D int (); U fn4(); // bad, fn returning a fn U& fn5(); // OK U* fn6(); // OK So the check we're looking for is probably if (TREE_CODE (type) =3D=3D FUNCTION_TYPE && (type_memfn_quals (type) !=3D TYPE_UNQUALIFIED || type_memfn_rqual (type) !=3D REF_QUAL_NONE)) but I think it should be put wherever we simulate declval().=