From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12998 invoked by alias); 26 Feb 2018 17:42:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 12981 invoked by uid 89); 26 Feb 2018 17:42:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Feb 2018 17:42:57 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C81637ED0D for ; Mon, 26 Feb 2018 17:42:56 +0000 (UTC) Received: from redhat.com (ovpn-204-51.brq.redhat.com [10.40.204.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5B5A60BE6; Mon, 26 Feb 2018 17:42:48 +0000 (UTC) Date: Mon, 26 Feb 2018 17:42:00 -0000 From: Marek Polacek To: GCC Patches , Jason Merrill Subject: C++ PATCH to fix ICE with constexpr operator"" (PR c++/84325) Message-ID: <20180226174238.GK2995@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-SW-Source: 2018-02/txt/msg01444.txt.bz2 The original testcase was invalid but I added seconds's constructor and made time_to_wait inline and now the testcase is accepted by clang++. But we ICE in replace_placeholders_r because we were checking TREE_CONSTANT on a type. With this patch we accept the code without crashing. (We require time_to_wait to be inline but clang++ does not.) Bootstrapped/regtested on x86_64-linux, ok for trunk? 2018-02-26 Marek Polacek PR c++/84325 * tree.c (replace_placeholders_r): Only check TREE_CONSTANT on non-types. * g++.dg/cpp1z/pr84325.C: New test. diff --git gcc/cp/tree.c gcc/cp/tree.c index 39c1ef28b2d..298517ff83a 100644 --- gcc/cp/tree.c +++ gcc/cp/tree.c @@ -3091,7 +3091,7 @@ replace_placeholders_r (tree* t, int* walk_subtrees, void* data_) replace_placeholders_t *d = static_cast(data_); tree obj = d->obj; - if (TREE_CONSTANT (*t)) + if (!TYPE_P (*t) && TREE_CONSTANT (*t)) { *walk_subtrees = false; return NULL_TREE; diff --git gcc/testsuite/g++.dg/cpp1z/pr84325.C gcc/testsuite/g++.dg/cpp1z/pr84325.C index e69de29bb2d..dddadc32692 100644 --- gcc/testsuite/g++.dg/cpp1z/pr84325.C +++ gcc/testsuite/g++.dg/cpp1z/pr84325.C @@ -0,0 +1,17 @@ +// PR c++/84325 +// { dg-do compile } +// { dg-options "-std=c++17" } + +struct seconds { int i_{0}; constexpr seconds (int) {} }; +template constexpr seconds operator""_s() { + return seconds(0); +} +constexpr seconds operator""_s(long double i) { + return seconds(0); +} +template +struct Param { + constexpr static inline seconds time_to_wait{10_s}; +}; +struct Empty {}; +Param p; Marek