From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 9408E3858C66 for ; Fri, 16 Aug 2024 20:07:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9408E3858C66 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9408E3858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723838877; cv=none; b=ptIluYzMivA9JTcUty50F9UcTYTejDJsq41IhF1btX9T+opnyyuuyYYpEebfDrEpm9MAeFQ4yYEdiGfG9By/niX87M309sokl49k/MtwPO8dQlFnfbuM55aIHaOFGwGkuZSLuH2LSYSRiXUzIPU94k+/7Z4mJjm0cmbvTIpcFBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723838877; c=relaxed/simple; bh=iIGYw5r7NCH2BCdtAWKSnMelF7DgB8823TK890d8I6o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=THD4yR6wyaOlsvexPk7oMz0D9JNJuaWcn7no9TsJHCrw1kQ2BTn2krLeQeSAGeSv9zB+4MS3ydxHIGXD/kkotzB1UwXU/kaXJSCWa1OATBZyCVgwnAJaJtl5Qi69n1pJx8Uqw8M8ONKhLKbHFxTH9F/dS4nn9gfQARm1gT3K/OE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723838875; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JdOLNx0Ch1Jc/nkk+1Vs6CdPmgdM9cm9yxn5dol+6LE=; b=Y9tco6fyY0u2AtunTvGRaIn2klvuuI3/YdIyFmjjwSKw3F7dz3SaEDprZ6jpEZFNBYmbIs nmdlhgTacWMUwTMz6YjyWldx7Ikkc2Q9srAobRIl8Tp60Bbey7aWheybZj3YgyCTJMZ+4l tB/iRasJVnZL8d5+shD2sjMC94Ou9uw= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-351-XLG9mEBEO1Ckg6h2RT_uMw-1; Fri, 16 Aug 2024 16:07:53 -0400 X-MC-Unique: XLG9mEBEO1Ckg6h2RT_uMw-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CF89D19560AB for ; Fri, 16 Aug 2024 20:07:52 +0000 (UTC) Received: from pdp-11.lan (unknown [10.22.65.34]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 018CE1955F38; Fri, 16 Aug 2024 20:07:51 +0000 (UTC) From: Marek Polacek To: Jason Merrill , GCC Patches Subject: [PATCH] c++: fix ICE in convert_nontype_argument [PR116384] Date: Fri, 16 Aug 2024 16:07:46 -0400 Message-ID: <20240816200746.119078-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? -- >8 -- Here we ICE since r14-8291 in C++11/C++14 modes. Fortunately this is an easy one. The important bit of r14-8291 is this: @@ -20056,9 +20071,12 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) RETURN (retval); } if (IMPLICIT_CONV_EXPR_NONTYPE_ARG (t)) - /* We'll pass this to convert_nontype_argument again, we don't need - to actually perform any conversion here. */ - RETURN (expr); + { + tree r = convert_nontype_argument (type, expr, complain); + if (r == NULL_TREE) + r = error_mark_node; + RETURN (r); + } which obviously means that instead of returning right away we go to convert_nontype_argument. When type is error_mark_node and we're in C++17, in convert_nontype_argument we go down this path: else if (INTEGRAL_OR_ENUMERATION_TYPE_P (type) || cxx_dialect >= cxx17) { expr = build_converted_constant_expr (type, expr, complain); if (expr == error_mark_node) return (complain & tf_error) ? NULL_TREE : error_mark_node; // ... } but pre-C++17, we take a different route and end up crashing on gcc_unreachable. It would of course also work to check for error_mark_node early in build_converted_constant_expr. PR c++/116384 gcc/cp/ChangeLog: * pt.cc (tsubst_expr) : Bail if tsubst returns error_mark_node. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/vt-116384.C: New test. --- gcc/cp/pt.cc | 2 ++ gcc/testsuite/g++.dg/cpp0x/vt-116384.C | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/vt-116384.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 8725a5eeb3f..684ee0c8a60 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -20217,6 +20217,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) case IMPLICIT_CONV_EXPR: { tree type = tsubst (TREE_TYPE (t), args, complain, in_decl); + if (type == error_mark_node) + RETURN (error_mark_node); tree expr = RECUR (TREE_OPERAND (t, 0)); if (dependent_type_p (type) || type_dependent_expression_p (expr)) { diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-116384.C b/gcc/testsuite/g++.dg/cpp0x/vt-116384.C new file mode 100644 index 00000000000..54d7f0774c5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-116384.C @@ -0,0 +1,26 @@ +// PR c++/116384 +// { dg-do compile { target c++11 } } + +namespace a { +template struct c; +template struct d; +} +namespace e { +namespace g { +template using h = void; +template class, typename...> struct detector {}; +template