From patchwork Thu Jan 3 20:36:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: C++ PATCH for c++/55753 (ICE with constexpr) From: Jason Merrill X-Patchwork-Id: 209309 Message-Id: <50E5EBB1.8020507@redhat.com> To: gcc-patches List Date: Thu, 03 Jan 2013 15:36:01 -0500 This is a bit I missed in my 55419 patch; if we aren't setting TREE_CONSTANT on TARGET_EXPRs in the constexpr code, we can't expect it in the template code. Tested x86_64-pc-linux-gnu, applying to trunk and 4.7. commit db160eb9b07b62f3696e7358c74e6d59c68385d8 Author: Jason Merrill Date: Thu Jan 3 14:43:05 2013 -0500 PR c++/55419 PR c++/55753 * pt.c (tsubst_copy_and_build) [TARGET_EXPR]: Don't touch TREE_CONSTANT. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1b3f039..09a0aa5 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14333,11 +14333,9 @@ tsubst_copy_and_build (tree t, case TARGET_EXPR: /* We can get here for a constant initializer of non-dependent type. FIXME stop folding in cp_parser_initializer_clause. */ - gcc_assert (TREE_CONSTANT (t)); { tree r = get_target_expr_sfinae (RECUR (TARGET_EXPR_INITIAL (t)), complain); - TREE_CONSTANT (r) = true; RETURN (r); } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor12.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor12.C new file mode 100644 index 0000000..a5a4b4d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor12.C @@ -0,0 +1,14 @@ +// PR c++/55753 +// { dg-options -std=c++11 } + +template +struct C { + constexpr C(const Tp& r) { } +}; + +template +struct B { + B() { + C cpl = C((true ? 1.0 : C())); + } +};