From patchwork Mon Apr 18 22:09:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ed Catmur X-Patchwork-Id: 1618566 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=catmur.uk header.i=@catmur.uk header.a=rsa-sha256 header.s=fm1 header.b=k7TwJ7lk; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=cOIy0S3q; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kj1Pf5YzJz9s0r for ; Tue, 19 Apr 2022 08:12:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DF4B63857372 for ; Mon, 18 Apr 2022 22:12:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by sourceware.org (Postfix) with ESMTPS id 14AE33857C44 for ; Mon, 18 Apr 2022 22:09:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 14AE33857C44 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=catmur.uk Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=catmur.uk Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id F34B232020F5; Mon, 18 Apr 2022 18:09:25 -0400 (EDT) Received: from imap47 ([10.202.2.97]) by compute4.internal (MEProxy); Mon, 18 Apr 2022 18:09:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catmur.uk; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1650319765; x=1650406165; bh=viRYjmxAb7 k4RB0hoaVEmaAZe25SLGWVJq/znJDfy7E=; b=k7TwJ7lk0Gb4ulhXN/vK6na21N ZJtwAwJ4Jj4hLJFHSXMIV0yyFT6rDrZDijMJHwIotv8E6TEMkXkar2OPO5AvLAb7 6ZoFMaxu33NKNtSlD+gP3murGgdFf0qnZL6K3mtjPUoL4SY7cxTtS8lpH7uZL3eh dE72ek/pGNJSCJbvWdc/hMz5lOveDJQvQD3ajuEnIoX/qH/O6Seev2yoiwiMtocJ 3ohN1KkfeIGrQr4rZT0X3YokIwUTtwQsqUvdR85HeFnz6DDyKKV0sa0KLiy99NYl iFoHH8+WPk47N3Lcu3XXpybNw9LFG79jsIusMuD/DVHO3mRt43zFGDoWoRWA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1650319765; x= 1650406165; bh=viRYjmxAb7k4RB0hoaVEmaAZe25SLGWVJq/znJDfy7E=; b=c OIy0S3qpP0DTcibrnxn1lJeHKA9RiFExchDJi/YGZF9BSaXW7SrViYYuI+c46tlo /2JDitXHr1o27C4jVi/Drh1476/BNLe6a0beJxbPk1HF6L9e7SVEr50ddTpXgEEU zBgDv84p+MzmPmmQm9ZtceL+aAJFsT/JiiUEfBZwuqsCI8EPB7xZdev8LMOjbrOq rXYVx1Qk/aE55ht7/0JdJXTFRwUmuqBdlalK7EhX6G7lyt7AGCYHfKuN1BWaT7+f xOsPLVS0o9RHr1th0xgzg2eCdOw543fq8J03kN7suMfHEiRRZoD4BcZoyocl+hdN LqNoLaOtcPAli4yOxSm9A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrvddtvddgtdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfgugcu vegrthhmuhhrfdcuoegvugestggrthhmuhhrrdhukheqnecuggftrfgrthhtvghrnhepgf fggeefhfegtdffuedvjefhheffieeltdefheeutdeigffggeelvddvveegvefgnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepvggusegtrghtmh hurhdruhhk X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 28B892740692; Mon, 18 Apr 2022 18:09:25 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-387-g7ea99c4045-fm-20220413.002-g7ea99c40 Mime-Version: 1.0 Message-Id: <2ed200df-ec89-4dfb-8855-80e6f1409b72@www.fastmail.com> In-Reply-To: References: <20f9f684-05be-4564-9a26-bbfadc64d133@www.fastmail.com> Date: Mon, 18 Apr 2022 23:09:04 +0100 From: "Ed Catmur" To: "Jason Merrill" Subject: [PATCH v2] c++: Fall through for arrays of T vs T cv [PR104996] X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Polacek , gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" If two arrays do not have the exact same element type including qualification, this could be e.g. f(int (&&)[]) vs. f(int const (&)[]), which can still be distinguished by the lvalue-rvalue tiebreaker. By tightening this branch (in accordance with the letter of the Standard) we fall through to the next branch, which tests whether they have different element type ignoring qualification and returns 0 in that case; thus we only actually fall through in the T[...] vs. T cv[...] case, eventually considering the lvalue-rvalue tiebreaker at the end of compare_ics. Bootstrapped and tested on x86_64-pc-linux-gnu. Signed-off-by: Ed Catmur PR c++/104996 gcc/cp/ChangeLog: * call.cc (compare_ics): When comparing list-initialization sequences, do not return early. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/initlist129.C: New test. --- gcc/cp/call.cc | 7 ++----- gcc/testsuite/g++.dg/cpp0x/initlist129.C | 6 ++++++ 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist129.C diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 51d8f6c3fb1..fa18d7f8f9d 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -11546,12 +11546,9 @@ compare_ics (conversion *ics1, conversion *ics2) P0388R4.) */ else if (t1->kind == ck_aggr && TREE_CODE (t1->type) == ARRAY_TYPE - && TREE_CODE (t2->type) == ARRAY_TYPE) + && TREE_CODE (t2->type) == ARRAY_TYPE + && same_type_p (TREE_TYPE (t1->type), TREE_TYPE (t2->type))) { - /* The type of the array elements must be the same. */ - if (!same_type_p (TREE_TYPE (t1->type), TREE_TYPE (t2->type))) - return 0; - tree n1 = nelts_initialized_by_list_init (t1); tree n2 = nelts_initialized_by_list_init (t2); if (tree_int_cst_lt (n1, n2)) diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist129.C b/gcc/testsuite/g++.dg/cpp0x/initlist129.C new file mode 100644 index 00000000000..4d4faa9e08d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist129.C @@ -0,0 +1,6 @@ +// PR c++/104996 +// { dg-do compile { target c++11 } } + +template char f(int (&&)[size]); +template int f(int const (&)[size]); +static_assert(sizeof(f({1, 2, 3})) == 1, "");