From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 17FC03858C56; Thu, 1 Sep 2022 21:58:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17FC03858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662069516; bh=a2o+RThihyD0r5qvxU5dhW6KB5TEoIsdQQ26WzRehRU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YlDV+565aMWQGxjoqRkvtE9E+VumNiDSavwJ1+2EwsldLcVO4FjMJDYQ5iioRX+V0 hv7dxwKuBqWBnaTkp7RZxckr7n8DwgOvwpx3pi8C7GpSA7keGqf1kDDfmd8nuCSoFv ewZe4ia3q0VP4S9K1FiTmcWjMs0K+Ev6FbqZVfpA= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits Date: Thu, 01 Sep 2022 21:58:34 +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: 6.1.0 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: 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=3D71579 --- Comment #20 from Jonathan Wakely --- template struct is_standard_layout : public integral_constant { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; This check is wrong. It passes for Incomplete[] but that's not valid for the trait. The precondition is: "remove_all_extents_t shall be a complete ty= pe or cv void." The __is_standard_layout built-in gets it right: /usr/include/c++/12/type_traits:743:38: error: invalid use of incomplete ty= pe =E2=80=98class Incomplete=E2=80=99 We have the same problem for is_trivial, is_trivially_copyable, is_pod, is_literal_type. I think we should remove the checks from those traits and just rely on the compiler to diagnose it. Maybe we should consider dropping all the static assertions from traits that are implemented using a compiler built-in. The __is_constructible(T, Args..= .) built-in already checks the precondition, so we're just doing unnecessary w= ork to repeat that check using __is_complete_or_unbounded.=