From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D96A13858D35; Sat, 25 Mar 2023 14:20:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D96A13858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679754006; bh=XrdGnIl9yvueNyCpbT4rfwMj6oTY530lpLAJtSk8DZ0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=F9j85wMXFXoMvYDgzwjJZdeu0t2YEN7H7Xbs085rt227s7r6w/xvZre/3TmEndVPh 8/5rtQ/fRhxgQIQH4QK92GGM+q9+CwQNyJNB3VYYql7IwN9CNJgGtJ8vEkVUHSrwAg 0ke6dabhAoJ7gfHYqV8mmYScDoduYwIBggybbhjw= From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBjKysvMTA5Mjc3XSBbMTMgUmVncmVzc2lvbl0gdHlwZV90?= =?UTF-8?B?cmFpdHM6MTQxNzozMDogZXJyb3I6IGludmFsaWQgdXNlIG9mIGluY29tcGxl?= =?UTF-8?B?dGUgdHlwZSDigJhjbGFzcyB2ODo6aW50ZXJuYWw6Oldhc21BcnJheeKAmQ==?= Date: Sat, 25 Mar 2023 14:20:05 +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.0 X-Bugzilla-Keywords: needs-bisection, needs-reduction, rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: ppalka at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109277 Patrick Palka changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ppalka at gcc dot gnu.org --- Comment #9 from Patrick Palka --- AFAICT the trait instantiation is legitimate, and this appears to be UB, he= re's a boiled down testcase: #include #include struct Object; struct MaybeObject; struct WasmArray; template struct is_subtype { static const bool value =3D std::is_base_of::value || (std::is_same::value = && std::is_convertible::valu= e); }; template struct TNode { TNode(); template::value>> TNode(const TNode&); // #1 TNode(const TNode&); // #2 }; std::tuple> node; The instantiation of std::is_convertible happens when synthesizing tuple> defaulted move constructor, for which = we need to perform overload resolution of TNode's constructors with a TNode&& argument, and when considering the template candidate #1 we need to instant= iate its default template argument which entails instantiation of is_convertible. In GCC 12 is_convertible for an incomplete type would silently return false= .=20 In GCC 13 the new built-in __is_convertible diagnoses this UB situation as a hard error. Clang's __is_convertible behaves like GCC 12's is_convertible = it seems. One fix is to define a move constructor for TNode, which causes GCC's perfe= ct candidate optimization (r11-7287-g187d0d5871b1fa) to kick in and avoid considering the template candidate #1. Another fix is to use std::conjunction/disjunction in is_subtype so that the condition properly short-circuits (is_base_of is true even for incomplete T).=