[Bug c++/36369] [4.3/4.4 Regression] may_alias broken with previous uses of non attributed type in some cases

2008-05-29 Thread pinskia at gcc dot gnu dot org


--- Comment #3 from pinskia at gcc dot gnu dot org  2008-05-29 13:48 ---
For my testcase with the C front-end:
;; *y = *(const long_a *) x-a
(insn 7 6 8 t.cc:12 (set (reg:SI 61)
(mem:SI (reg/v/f:SI 59 [ x ]) [0 S4 A32])) -1 (nil))

While with the C++ front-end:
;; *y = *(const long_a *) x-a
(insn 7 6 8 t.cc:12 (set (reg:SI 61)
(mem:SI (reg/v/f:SI 59 [ x ]) [3 S4 A32])) -1 (nil))

I think the issue here is really the canonical type is set for C++ front-end
which is wrong for may_alias types.

This is wrong code and not just a warning as shown by the rtl expansion.


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

   Severity|normal  |critical
   Keywords||wrong-code
Summary|[4.3/4.4 Regression] Type   |[4.3/4.4 Regression]
   |punning warning with|may_alias broken with
   |may_alias attribute depends |previous uses of non
   |on unrelated class  |attributed type in some
   |definition  |cases


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36369



[Bug c++/36369] [4.3/4.4 Regression] may_alias broken with previous uses of non attributed type in some cases

2008-05-29 Thread jakub at gcc dot gnu dot org


--- Comment #4 from jakub at gcc dot gnu dot org  2008-05-29 13:54 ---
Quick hack that fixes this:
--- gcc/alias.c.jj  2008-05-18 22:14:23.0 +0200
+++ gcc/alias.c 2008-05-29 15:47:30.0 +0200
@@ -605,6 +605,8 @@ get_alias_set (tree t)

   /* Variant qualifiers don't affect the alias set, so get the main
  variant. If this is a type with a known alias set, return it.  */
+  if (TYPE_ALIAS_SET_KNOWN_P (t))
+return TYPE_ALIAS_SET (t);
   t = TYPE_MAIN_VARIANT (t);
   if (TYPE_ALIAS_SET_KNOWN_P (t))
 return TYPE_ALIAS_SET (t);
--- gcc/c-common.c.jj   2008-05-29 10:20:11.0 +0200
+++ gcc/c-common.c  2008-05-29 15:46:29.0 +0200
@@ -568,6 +568,7 @@ static tree handle_vector_size_attribute
  bool *);
 static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
 static tree handle_nothrow_attribute (tree *, tree, tree, int, bool *);
+static tree handle_may_alias_attribute (tree *, tree, tree, int, bool *);
 static tree handle_cleanup_attribute (tree *, tree, tree, int, bool *);
 static tree handle_warn_unused_result_attribute (tree *, tree, tree, int,
 bool *);
@@ -663,7 +664,8 @@ const struct attribute_spec c_common_att
  handle_nonnull_attribute },
   { nothrow,0, 0, true,  false, false,
  handle_nothrow_attribute },
-  { may_alias, 0, 0, false, true, false, NULL },
+  { may_alias, 0, 0, false, true, false,
+ handle_may_alias_attribute },
   { cleanup,   1, 1, true, false, false,
  handle_cleanup_attribute },
   { warn_unused_result, 0, 0, false, true, true,
@@ -6396,6 +6398,18 @@ handle_nothrow_attribute (tree *node, tr
   return NULL_TREE;
 }

+/* Handle a may_alias attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_may_alias_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+   int ARG_UNUSED (flags),
+   bool *ARG_UNUSED (no_add_attrs))
+{
+  TYPE_ALIAS_SET (*node) = 0;
+  return NULL_TREE;
+}
+
 /* Handle a cleanup attribute; arguments as in
struct attribute_spec.handler.  */



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36369