From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 27AA63858C60; Tue, 2 May 2023 07:36:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27AA63858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683012972; bh=I4V1iQwAhdIwSUqDAFIuT/ab9jyHH3fgspOCKMeq9V4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=p4nOHgn/P2PEUXNuuiMMUBLpvolh6gFmM3mjbHVq1pG9GzWWYVR+aNm0BE+PfL3hr /9gNSYaxE3JgiOCub935ApzTP8ST46HIFPJlru6oCTe2duZpxIGXH/iHvNc++jD4uz yS8rVc3rxLqJS/RbEZeKICB2UO19gcBjSJUW4omQ= From: "jakub 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 07:36:11 +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: jakub 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 #6 from Jakub Jelinek --- Not sure about the from case, but what do I know about C++? While To type is directly returned from a function, std::declval doesn't re= turn >From but >From &&. #include using F1 =3D int (int); using T1 =3D int (*) (int); static_assert (std::is_convertible_v); using F2 =3D int (int) const; using T2 =3D int (*) (int); static_assert (!std::is_convertible_v); using F3 =3D int (*) (int); using T3 =3D int (int); static_assert (!std::is_convertible_v); using F4 =3D int (*) (int); using T4 =3D int (int) const; static_assert (!std::is_convertible_v); passes in both g++ 12 and clang++. And, on using F1 =3D int (int); using T1 =3D int (*) (int); static_assert (__is_convertible(F1, T1)); using F2 =3D int (int) const; using T2 =3D int (*) (int); static_assert (!__is_convertible(F2, T2)); using F3 =3D int (*) (int); using T3 =3D int (int); static_assert (!__is_convertible(F3, T3)); using F4 =3D int (*) (int); using T4 =3D int (int) const; static_assert (!__is_convertible(F4, T4)); clang++ emits: /tmp/2a.C:6:34: error: non-member function of type 'F2' (aka 'int (int) con= st') cannot have 'const' qualifier static_assert (!__is_convertible(F2, T2)); ^ /tmp/2a.C:6:1: error: static_assert failed due to requirement '!__is_convertible(int (int), int (*)(int))' static_assert (!__is_convertible(F2, T2)); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~ /tmp/2a.C:12:38: error: non-member function of type 'T4' (aka 'int (int) const') cannot have 'const' qualifier static_assert (!__is_convertible(F4, T4)); ^ while g++ trunk /tmp/2a.C:6:16: error: static assertion failed 6 | static_assert (!__is_convertible(F2, T2)); | ^~~~~~~~~~~~~~~~~~~~~~~~~=