diff mbox

C++ PATCH for c++/46335 (C++0x ICE with T() default argument)

Message ID 4CD8C439.9000305@redhat.com
State New
Headers show

Commit Message

Jason Merrill Nov. 9, 2010, 3:47 a.m. UTC
As part of the constexpr work I've started setting TREE_CONSTANT on a 
TARGET_EXPR wrapped around a constant CONSTRUCTOR; this confused 
bot_manip, which assumed that there couldn't be anything interesting 
within a TREE_CONSTANT expression.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit abf9d4a2b6eabe2b6d3a2cff5be58ef3708e843b
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Nov 8 18:40:07 2010 -0600

    	PR c++/46335
    	* tree.c (bot_manip): Check TREE_SIDE_EFFECTS as well.
diff mbox

Patch

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 5440e10..462e35f 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1763,11 +1763,10 @@  bot_manip (tree* tp, int* walk_subtrees, void* data)
   splay_tree target_remap = ((splay_tree) data);
   tree t = *tp;
 
-  if (!TYPE_P (t) && TREE_CONSTANT (t))
+  if (!TYPE_P (t) && TREE_CONSTANT (t) && !TREE_SIDE_EFFECTS (t))
     {
       /* There can't be any TARGET_EXPRs or their slot variables below
-	 this point.  We used to check !TREE_SIDE_EFFECTS, but then we
-	 failed to copy an ADDR_EXPR of the slot VAR_DECL.  */
+	 this point.  */
       *walk_subtrees = 0;
       return NULL_TREE;
     }
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C
new file mode 100644
index 0000000..1413b24
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C
@@ -0,0 +1,12 @@ 
+// PR c++/46335
+// { dg-options -std=c++0x }
+
+struct T { };
+struct A {
+    A(const T &tr =T()) {}
+};
+struct B {
+    A k;
+};
+B kk_;
+A fk_;