From patchwork Tue Jul 9 16:13:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Martin X-Patchwork-Id: 1958537 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nasilyan.com header.i=@nasilyan.com header.a=rsa-sha256 header.s=xce2voaxvxhmx73p47whqmbxwwvd7qkl header.b=JChXBQnj; dkim=pass (1024-bit key; unprotected) header.d=amazonses.com header.i=@amazonses.com header.a=rsa-sha256 header.s=uku4taia5b5tsbglxyj6zym32efj7xqv header.b=I7OBCUam; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WJQz45Wl0z1xrJ for ; Wed, 10 Jul 2024 02:13:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E9891386C5B4 for ; Tue, 9 Jul 2024 16:13:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from a2-10.smtp-out.eu-west-1.amazonses.com (a2-10.smtp-out.eu-west-1.amazonses.com [54.240.2.10]) by sourceware.org (Postfix) with ESMTPS id CB3A7386D61A for ; Tue, 9 Jul 2024 16:13:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB3A7386D61A Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=nasilyan.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eu-west-1.amazonses.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CB3A7386D61A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=54.240.2.10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720541612; cv=none; b=sSJWsKUcWVDQbGfwusuwxAjQba4FYHYHsviNHRuqe2UDdHurYUSKmNgRO1e5fqUYJoZQy3ADrdvLyFsMXyoO2ByHP1/4KElqUlDfwG5I2v+613zNjjqHZA4fkXzfnEHqF6flll/Nraj+2UtqVcIc8ad8fvMNMFGya4nCiIvwmuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720541612; c=relaxed/simple; bh=rZthuewE7W92tIxeAtjw3HprB6bCvUtqBi6dlZKixIE=; h=DKIM-Signature:DKIM-Signature:Subject:From:To:Date:Mime-Version: Message-ID; b=VQlMAXU6G4EFU5uU3CQZaTP59ylPXK594a79xXHSg06gVYRG0MxzCsG56/gih0+PwlSxnBZyFgGFRq2Ht8xwnPSnRHqiGqLUo5tfR3isfojeO9dXxr29LDexuzZ1I28DSgySgae4vtHXg9yXySsVakbVmUB/IX/hZTC9iu7nEQY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=xce2voaxvxhmx73p47whqmbxwwvd7qkl; d=nasilyan.com; t=1720541608; h=Subject:From:To:Date:Mime-Version:Content-Type:Content-Transfer-Encoding:References:Message-Id; bh=rZthuewE7W92tIxeAtjw3HprB6bCvUtqBi6dlZKixIE=; b=JChXBQnj7u2mY6qACELgDxAd3FSt1XAhvYh7/3FPYyAOeelTmS7gV6vQbTzX27ld 2ZJMYhJHxqljyIUACqTMEPk2ge3oO6OBKqyt0EQYsDbONhxfdF9UmHCHg5xGPnAeHSB NcYuEhL5zySQup1xJ+GFl85XI0Y7rZK5By+5gWgs= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=uku4taia5b5tsbglxyj6zym32efj7xqv; d=amazonses.com; t=1720541608; h=Subject:From:To:Date:Mime-Version:Content-Type:Content-Transfer-Encoding:References:Message-Id:Feedback-ID; bh=rZthuewE7W92tIxeAtjw3HprB6bCvUtqBi6dlZKixIE=; b=I7OBCUamTomOfwh1VG4aqLIxTRZBU1mAoMp0pJ29kCisMQ5+yOpZfY51dxGh6Vf9 0MxM55ZLsEMqUxYtIFhSTiUWTlz3XBl+jDHnZNfmnaYHihTTfpzhZl/YBpKPVnrX00e 6KdSuiRmgvTiJ0+JioqUP3w0CsoQi8kZPIFp4w00= Subject: [PATCH] c++: Fix ICE on valid involving variadic constructor [PR111592] From: =?utf-8?q?Simon_Martin?= To: =?utf-8?q?gcc-patches=40gcc=2Egnu=2Eorg?= Date: Tue, 9 Jul 2024 16:13:28 +0000 Mime-Version: 1.0 References: <20240709161325.64166-1-simon@nasilyan.com> X-Mailer: Amazon WorkMail Thread-Index: AQHa0hruAPS7+xUGShaqTYtquup25A== Thread-Topic: [PATCH] c++: Fix ICE on valid involving variadic constructor [PR111592] X-Original-Mailer: git-send-email 2.44.0 X-Wm-Sent-Timestamp: 1720541607 Message-ID: <01020190984579a0-d9edaf97-be78-416c-aa9b-203556ebadb9-000000@eu-west-1.amazonses.com> Feedback-ID: ::1.eu-west-1.b24dn6frgCi6dh20skzbuMRr7UL8M6Soir/3ogtEjHQ=:AmazonSES X-SES-Outgoing: 2024.07.09-54.240.2.10 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org We currently ICE upon the following valid code, due to the fix made through commit 9efe5fbde1e8 === cut here === struct ignore { ignore(...) {} }; template void InternalCompilerError(Args... args) { ignore{ ignore(args) ... }; } int main() { InternalCompilerError(0, 0); } === cut here === Change 9efe5fbde1e8 avoids infinite recursion in build_over_call by returning error_mark_node if one invokes ignore::ignore(...) with an argument of type ignore, because otherwise we end up calling convert_arg_to_ellipsis for that argument, and recurse into build_over_call with the exact same parameters. This patch tightens the condition to only return error_mark_node if there's one and only one parameter to the call being processed - otherwise we won't infinitely recurse. Successfully tested on x86_64-pc-linux-gnu. PR c++/111592 gcc/cp/ChangeLog: * call.cc (build_over_call): Only error out if there's a single parameter of type A in a call to A::A(...). gcc/testsuite/ChangeLog: * g++.dg/cpp0x/variadic186.C: New test. --- gcc/cp/call.cc | 1 + gcc/testsuite/g++.dg/cpp0x/variadic186.C | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic186.C diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 83070b2f633..0e4e9a80408 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -10335,6 +10335,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) a = decay_conversion (a, complain); } else if (DECL_CONSTRUCTOR_P (fn) + && vec_safe_length (args) == 1 && same_type_ignoring_top_level_qualifiers_p (DECL_CONTEXT (fn), TREE_TYPE (a))) { diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic186.C b/gcc/testsuite/g++.dg/cpp0x/variadic186.C new file mode 100644 index 00000000000..4a25a1a96bf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic186.C @@ -0,0 +1,11 @@ +// PR c++/111592 +// { dg-do compile { target c++11 } } + +struct ignore { ignore(...) {} }; + +template +void InternalCompilerError(Args... args) +{ ignore{ ignore(args) ... }; } + +int main() +{ InternalCompilerError(0, 0); }