diff mbox

[C++/66270] another may_alias crash

Message ID 5565B793.9090709@acm.org
State New
Headers show

Commit Message

Nathan Sidwell May 27, 2015, 12:24 p.m. UTC
On 05/26/15 15:00, Nathan Sidwell wrote:
> On 05/25/15 21:18, Jason Merrill wrote:

>> Hmm, are you seeing a case where TYPE_CANONICAL (to_type) has the may_alias
>> attribute?
>
> Yes.  This occurs when the newly created TRCAA pointer is to a self-canonical
> type.  The
>   else if (TYPE_CANONICAL (to_type) != to_type)
> is false, so the newly created pointer is self-canonical too (and has TRCAA).
>
> If the canonical type should not have TRCAA we need to change the if condition to:
>    else if (TYPE_CANONICAL (to_type) != to_type || could_alias_all)
>
> where COULD_ALIAS_ALL is the incoming CAN_ALIAS_ALL value.  Does that make sense?
>
> Making that change does stop  the ICE I was seeing, but I've not done a full
> test yet.

Here's a patch implementing that change,  When build_pointer_type_for_mode is 
passed true for CAN_ALIAS_ALL, we force creating a canonical type, continuing to 
pass false for that pointer's creation.

booted & tested on x86-64-linux, ok?

nathan
diff mbox

Patch

2015-05-25  Nathan Sidwell  <nathan@acm.org>

	PR c++/66270
	* tree.c (build_pointer_type_for_mode): Canonical type does not
	inherit can_alias_all.
	(build_reference_type_for_mode): Likewise.

	PR c++/66270
	* g++.dg/ext/alias-canon3.C: New.

Index: testsuite/g++.dg/ext/alias-canon3.C
===================================================================
--- testsuite/g++.dg/ext/alias-canon3.C	(revision 0)
+++ testsuite/g++.dg/ext/alias-canon3.C	(working copy)
@@ -0,0 +1,12 @@ 
+// { dg-do compile }
+// PR c++/66270
+
+typedef float __m256 __attribute__ (( __vector_size__(32), __may_alias__ ));
+struct A {
+  __m256 ymm;
+  const float &f() const;
+};
+
+const float &A::f() const {
+  return ymm[1];
+}
Index: tree.c
===================================================================
--- tree.c	(revision 223636)
+++ tree.c	(working copy)
@@ -7719,6 +7719,7 @@  build_pointer_type_for_mode (tree to_typ
 			     bool can_alias_all)
 {
   tree t;
+  bool could_alias = can_alias_all;
 
   if (to_type == error_mark_node)
     return error_mark_node;
@@ -7756,7 +7757,7 @@  build_pointer_type_for_mode (tree to_typ
 
   if (TYPE_STRUCTURAL_EQUALITY_P (to_type))
     SET_TYPE_STRUCTURAL_EQUALITY (t);
-  else if (TYPE_CANONICAL (to_type) != to_type)
+  else if (TYPE_CANONICAL (to_type) != to_type || could_alias)
     TYPE_CANONICAL (t)
       = build_pointer_type_for_mode (TYPE_CANONICAL (to_type),
 				     mode, false);
@@ -7786,6 +7787,7 @@  build_reference_type_for_mode (tree to_t
 			       bool can_alias_all)
 {
   tree t;
+  bool could_alias = can_alias_all;
 
   if (to_type == error_mark_node)
     return error_mark_node;
@@ -7823,7 +7825,7 @@  build_reference_type_for_mode (tree to_t
 
   if (TYPE_STRUCTURAL_EQUALITY_P (to_type))
     SET_TYPE_STRUCTURAL_EQUALITY (t);
-  else if (TYPE_CANONICAL (to_type) != to_type)
+  else if (TYPE_CANONICAL (to_type) != to_type || could_alias)
     TYPE_CANONICAL (t)
       = build_reference_type_for_mode (TYPE_CANONICAL (to_type),
 				       mode, false);