C++ PATCH for c++/49290 (ICE regression on *(T*)(ar+10))

Message ID 4DF79A7C.3060308@redhat.com
State New
Headers show

Commit Message

Jason Merrill June 14, 2011, 5:29 p.m.
In this testcase, we were hitting an assert that I put in to make sure 
that fold_indirect_ref_1 was doing its job and folding everything that 
ought to be folded.  But fold_indirect_ref_1 doesn't want to mess with 
type identity, so it can't fold if, say, the array element type has 
different cv-quals from the desired result.  After some discussion, I'm 
copying fold_indirect_ref_1 into the front end so I can be more flexible 
about type matching.

For 4.6 I'll just disable the assert to avoid the regression on 
non-constexpr code and treat the expression as non-constant.

Tested x86_64-pc-linux-gnu, applying to trunk.


commit 6b67d63a289ca3eabc15dc7d9be34a603e45810f
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Jun 14 13:19:32 2011 -0400

    2011-06-14  Jason Merrill  <jason@redhat.com>

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index cc775b3..2b48224 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -6793,8 +6793,6 @@  cxx_eval_indirect_ref (const constexpr_call *call, tree t,
   else if (TREE_CODE (sub) == ADDR_EXPR
-      gcc_assert (!same_type_ignoring_top_level_qualifiers_p
-		  (TREE_TYPE (TREE_TYPE (sub)), TREE_TYPE (t)));
       /* FIXME Mike Miller wants this to be OK.  */
       if (!allow_non_constant)
 	error ("accessing value of %qE through a %qT glvalue in a "
diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/49290.C b/gcc/testsuite/g++.dg/cpp0x/regress/49290.C
new file mode 100644
index 0000000..71e46c5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/regress/49290.C
@@ -0,0 +1,12 @@ 
+typedef unsigned T;
+struct S
+  T foo (void);
+  static unsigned s1[16];
+S::foo ()
+  T u = *(T *) (s1 + 10);
+  return u;