diff mbox

C++ PATCH for c++/46670 (ICE with dependent array ref in C++0x mode)

Message ID 4D0BA200.9090204@redhat.com
State New
Headers show

Commit Message

Jason Merrill Dec. 17, 2010, 5:46 p.m. UTC
The constexpr changes mean that we check a lot more expressions for 
possibly being null pointer constants; in this testcase this broke 
because we weren't testing the dependency of an ARRAY_REF properly.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit bfc1b301c86e9c4c029fcc942919fac810d32483
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Dec 16 17:33:23 2010 -0500

    	PR c++/46670
    	* pt.c (value_dependent_expression_p) [ARRAY_REF]: Handle
    	properly.
diff mbox

Patch

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index a696d3b..49016b3 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -18108,6 +18108,10 @@  value_dependent_expression_p (tree expression)
       return ((value_dependent_expression_p (TREE_OPERAND (expression, 0)))
 	      || (value_dependent_expression_p (TREE_OPERAND (expression, 2))));
 
+    case ARRAY_REF:
+      return ((value_dependent_expression_p (TREE_OPERAND (expression, 0)))
+	      || (value_dependent_expression_p (TREE_OPERAND (expression, 1))));
+
     case ADDR_EXPR:
       {
 	tree op = TREE_OPERAND (expression, 0);
diff --git a/gcc/testsuite/g++.dg/constexpr-null1.C b/gcc/testsuite/g++.dg/constexpr-null1.C
new file mode 100644
index 0000000..44cf9a0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/constexpr-null1.C
@@ -0,0 +1,11 @@ 
+// PR c++/46670
+// { dg-options -std=c++0x }
+
+extern unsigned char __TBB_ReverseByte(unsigned char src);
+extern unsigned char *reversed;
+template<typename T> T __TBB_ReverseBits(T src)
+{
+  unsigned char *original = (unsigned char *) &src;
+  for( int i = sizeof(T)-1; i--; )
+    reversed[i] = __TBB_ReverseByte( original[sizeof(T)-i-1] );
+}