This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH for c++/47950 (ICE with condition in template)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 03 Mar 2011 11:52:24 -0500
- Subject: Re: C++ PATCH for c++/47950 (ICE with condition in template)
- References: <4D6F223D.2070608@redhat.com>
On 03/03/2011 12:08 AM, Jason Merrill wrote:
The problem here was that we were folding the initializer too many
times, so we lost the TREE_CONSTANT on the TARGET_EXPR. Since we already
fold in cp_parser_initializer_clause, it's redundant to do so in
cp_parser_condition as well.
It occurred to me that a more robust fix would be to make it so
redundant folding doesn't cause an ICE here.
Tested x86_64-pc-linux-gnu, applied to trunk.
commit a0390d566c766d20b49735be27913666a1e7ffad
Author: Jason Merrill <jason@redhat.com>
Date: Thu Mar 3 00:08:21 2011 -0500
PR c++/47950
* pt.c (tsubst_copy_and_build) [TARGET_EXPR]: Retain TREE_CONSTANT.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 4b262d0..60b2699 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13368,7 +13368,11 @@ tsubst_copy_and_build (tree t,
/* 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));
- return get_target_expr (RECUR (TARGET_EXPR_INITIAL (t)));
+ {
+ tree r = get_target_expr (RECUR (TARGET_EXPR_INITIAL (t)));
+ TREE_CONSTANT (r) = true;
+ return r;
+ }
default:
/* Handle Objective-C++ constructs, if appropriate. */