From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 97A623858D28; Mon, 5 Sep 2022 21:16:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97A623858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662412587; bh=Pl9f2Lf1MlciPzPB+JYZ77ylfezjXnNT3ioxpLcSGsk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=B0uJcoEYlZcqVU5+/oJfNEyG85wyqsbCEJD2CwAyrh7m1PSMp9tXtFlty8UBSm2UE OqBVbnHSQ1P8IBbDAXioOYn/D1p2qfxqfuZjn72InxehcOauB66AC+P82oMWjngnl7 ElJQp1xhjk7IzzEdGC6fjamlYQOInZuH8bh3/1Os= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106838] Built-in traits have wrong preconditions Date: Mon, 05 Sep 2022 21:16:27 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi 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: --- 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=3D106838 --- Comment #3 from Jonathan Wakely --- We have three main kinds of trait preconditions. A. "T shall be a complete type, (possibly cv-qualified) void, or an array of unknown bound." This only allows T[1] is T is complete, but always allows T[], even if incomplete. The rationale here is that we can always tell if T[] is constructible, destructible, assignable etc (the answer is always no), but to tell whether T[1] is constructible we need to know about T. B. "remove_all_extents_t shall be a complete type or cv void." This only allows T[] and T[1] when T is complete. The rationale is that we need to know properties of the array element, e.g.= to tell whether T[1] is an aggregate, we need to know if T is an aggregate. C. "If T is a non-union class type, T shall be a complete type." This always allows T[] and T[1], even if T is incomplete, and allows incomp= lete T is T is a union type. The rationale is that these traits are always false for array types, e.g. T= [] is not a polymorphic type, even if T is polymorphic. Currently it seems that check_trait_type only supports preconditions of kin= d A, and since r13-25 it allows all arrays, when it should only allow unbounded arrays. So e.g. it doesn't reject __is_constructible(Incomplete[1]) even th= ough it can't know the answer. I think check_trait_type could be adjusted to handle kinds A and B, by addi= ng a bool parameter, but maybe kind C should be checked by a separate function, = as it is quite different.=