From patchwork Thu Jun 14 00:01:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 929129 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-479683-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="TDCrGvyu"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 415kMM4kSTz9s3q for ; Thu, 14 Jun 2018 10:02:22 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=G/xAbOlPm92tDZV22mNjS/1hK5zd77dNhWRIDabHh0kUaG 3ZxCCcNk9PLAcw0l+lPOeADFdICmvPRS3XdPLw3GQYyjrP+h62JDbBR6JfQ+iCrz G7ZID4PTlyEOMdDQoeWjkXlV8fPfdjrnTAsd7f8qnWyMp+KuWCMgodgPAUlg8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=JewzivmOnQM3ybEvMI3JBCz4ITk=; b=TDCrGvyuuzrgSjsF4Bvr 3DU3px4r6CIAdq5tWugSE342sqxmSQhHFz3BoDzRt5n0hDUhxql8cqn38S39L1+p Gnjtz9+3qg9RpxSKkEgh5+gT/Pzh1wuxmbEGFteJyKEhFok0cISyQDEk2zpa47On dEbMF+qIEj82aBzUxPvHjrs= Received: (qmail 86579 invoked by alias); 14 Jun 2018 00:02:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 86408 invoked by uid 89); 14 Jun 2018 00:01:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=nsdmi, NSDMI, sk:nsdmit, sk:nsdmi-t X-HELO: mail-ot0-f181.google.com Received: from mail-ot0-f181.google.com (HELO mail-ot0-f181.google.com) (74.125.82.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Jun 2018 00:01:50 +0000 Received: by mail-ot0-f181.google.com with SMTP id h6-v6so5063955otj.0 for ; Wed, 13 Jun 2018 17:01:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=4k5MChmn6zv8Ui7GTqgwzQkIqiHY8wc0OAnIPlM2jUg=; b=klrUxRxmITw6woDPXSmAZLFLQx8rFRcJUpPlHz2w2aRh4h34F3ENcIt94g22qD+WdI gbdCre2CVDTfC0ItRGICJdTXz9C50BHYNqYbQ5Zi7uqp0v0FuggnZmfPsIuVCDIxedr3 2aKh29pkzrLkhp4XTSUdZ3Ho+tbEjivAqhFwiAVhWEUnbgXr7LGfa3qGW2ns9C5n0Y9d JS/DBG/Yh6VOu5tLmS4+J93bnQWk0IBZ0HjqwbAo4oDMFF4U7zVuaZfI6UEzifIcOmXN JazVgB1n6rqzOLfgX4F/zRwSzTxPDI5L31zAn53jacfFnp16Fc+AySznoDEhUlIipjjO qNHA== X-Gm-Message-State: APt69E1Wn5wIAyfMBREZsk1AO9UsEvsie3whYw8DFuRxJx2bfMq7X23U 4R0i3TyNArNGqIUpmw2QDU+yuRX2YcGuWo6SMpdr+br5 X-Google-Smtp-Source: ADUXVKLqGmvYYBWVzqo7PglDERHek5i8008dBUyzqU7pwW9G9TWomYvcKkRIQEu1tlXga6ps3XB9MC/KwDe9kOSF0yo= X-Received: by 2002:a9d:34c3:: with SMTP id t3-v6mr171055otd.313.1528934506467; Wed, 13 Jun 2018 17:01:46 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:dd0:0:0:0:0:0 with HTTP; Wed, 13 Jun 2018 17:01:25 -0700 (PDT) From: Jason Merrill Date: Wed, 13 Jun 2018 20:01:25 -0400 Message-ID: Subject: C++ PATCH for c++/86099, ICE with NSDMI To: gcc-patches List X-IsSubscribed: yes In this testcase, the compiler is trying to evaluate a constant-expression which involves a trivial defaulted copy constructor. My patch for CWG 1581 had us instantiate any function that appears in a potential constant expression, but that's not what we want for a trivial constructor like this. Tested x86_64-pc-linux-gnu, applying to trunk. commit b71b855538a05716e704d02f636b8820faec3e62 Author: Jason Merrill Date: Wed Jun 13 17:51:44 2018 -0400 PR c++/86099 - ICE with trivial copy and non-trivial default ctor. * constexpr.c (instantiate_cx_fn_r): Don't synthesize trivial constructors. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 97a338535db..93de6162c04 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -4841,6 +4841,7 @@ instantiate_cx_fn_r (tree *tp, int *walk_subtrees, void */*data*/) if (TREE_CODE (*tp) == FUNCTION_DECL && DECL_DECLARED_CONSTEXPR_P (*tp) && !DECL_INITIAL (*tp) + && !trivial_fn_p (*tp) && DECL_TEMPLOID_INSTANTIATION (*tp)) { ++function_depth; diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template18.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template18.C new file mode 100644 index 00000000000..e3520bc6b44 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template18.C @@ -0,0 +1,43 @@ +// PR c++/86099 +// { dg-do compile { target c++11 } } + +template struct e { static constexpr int c = a; }; +template using d = e; +template struct aa; +template struct j; +template struct j : aa::h {}; +template struct n : d {}; +template l m(int); +template auto ab() -> decltype(m(0)); +template struct p; +template struct p : e()))> {}; +template struct r; +class s; +template +struct ac : j, p, q...>> {}; +template struct ae : ac {}; +template struct aa { typedef ad h; }; +template struct w : j>, d> {}; +template struct r { + t f; + int af; + r(r &&) = default; +}; +template ::c, k>::h> void v(k *); +template ah aj(ag x, ah, ai) { v(x); return 0; } +template struct y { typedef int ak; }; +template class z { +public: + template void al(); +}; +template template void z::al() { + r *u; + typename y::ak a = aj(u, a, int()); +} +class s { + char *an = nullptr; +}; +void ao() { + z b; + b.al(); +}