From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A323B3882053; Thu, 13 Jun 2024 18:14:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A323B3882053 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1718302447; bh=a/w1cFys/xAd3u8HcTtaRsIPCL8eNES6akuBV/GUjNY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=yTTmneVJ0xT7ehuVCf18Ez2fPg5WkyMp6VguAIpHNEL5hFblKzhz8wUlSUPaYg66C 4yohZHqk1y4KoYtKyTgZ8DHU76X7e99ynUAYlTfdfPAh6vk42BZIDoiMKxjHvgq6lm 2mp5d0Q7o31x7948+dNQz1twFIwyk4xAPoH5Mhow= From: "mital at mitalashok dot co.uk" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/115476] [13/14/15 Regression] __has_unique_object_representation ICE with array of uninstantiated type of unknown bound Date: Thu, 13 Jun 2024 18:14:07 +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: 15.0 X-Bugzilla-Keywords: ice-on-invalid-code, ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mital at mitalashok dot co.uk 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.4 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=3D115476 --- Comment #7 from Mital Ashok --- I think the issue is the same as it was in Clang The preconditions for `has_unique_object_representations` is https://eel.is/c++draft/type.traits#tab:meta.unary.prop-row-47-column-3-sen= tence-1 > T shall be a complete type, cv void, or an array of unknown bound. Which is implemented in GCC as `check_trait_type (type1, /* kind =3D */ 1)` https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dblob;f=3Dgcc/cp/semantics.cc;h=3D0= 8f5f245e7d11a76b975bb04c0075ded1b3ca8ba;hb=3D609764a42f0cd3f6358562cab98fc2= 20d3d2d9fd#l12969 However, unlike the other traits with the same preconditions (like `__is_assignable(T, U)` for both of its type arguments), instead of simply being `false` when given an array with unknown bounds, it recurses in, so it implicitly has a precondition that "T is cv void or std::remove_all_extents_t is complete", which should be checked with `check_trait_type (type1, /* kind =3D */ 2)`. `__has_trivial_destructor` also seems to be miscategorized as kind =3D 1 to= o, leading to this unintended result: struct Foo; static_assert(__has_trivial_destructor(Foo[])); struct Foo { ~Foo(); }; static_assert(!__has_trivial_destructor(Foo[]));=