https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119474

--- Comment #9 from Andrew Stubbs <ams at gcc dot gnu.org> ---
This patch fixes the -O1 failure, for *this* testcase:

diff --git a/gcc/tree.cc b/gcc/tree.cc
index eccfcc89da40..4bfdb7a938e7 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -7085,11 +7085,8 @@ build_pointer_type_for_mode (tree to_type, machine_mode
mode,
   if (to_type == error_mark_node)
     return error_mark_node;

-  if (mode == VOIDmode)
-    {
-      addr_space_t as = TYPE_ADDR_SPACE (to_type);
-      mode = targetm.addr_space.pointer_mode (as);
-    }
+  addr_space_t as = TYPE_ADDR_SPACE (to_type);
+  mode = targetm.addr_space.pointer_mode (as);

   /* If the pointed-to type has the may_alias attribute set, force
      a TYPE_REF_CAN_ALIAS_ALL pointer to be generated.  */
@@ -7121,6 +7118,7 @@ build_pointer_type_for_mode (tree to_type, machine_mode
mode,
   TYPE_REF_CAN_ALIAS_ALL (t) = can_alias_all;
   TYPE_NEXT_PTR_TO (t) = TYPE_POINTER_TO (to_type);
   TYPE_POINTER_TO (to_type) = t;
+  TYPE_ADDR_SPACE (t) = TYPE_ADDR_SPACE (to_type);

   /* During LTO we do not set TYPE_CANONICAL of pointers and references.  */
   if (TYPE_STRUCTURAL_EQUALITY_P (to_type) || in_lto_p)


This is clearly wrong though, because the address space that the pointer is
*in* doesn't have to be the same as the one it *points to*, so I need a better
solution.

Any suggestions where to start?

Reply via email to