This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/80334] [7 Regression] Segfault when taking address of copy of unaligned struct
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 06 Apr 2017 09:36:42 +0000
- Subject: [Bug target/80334] [7 Regression] Segfault when taking address of copy of unaligned struct
- Auto-submitted: auto-generated
- References: <bug-80334-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80334
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fix:
Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c (revision 246724)
+++ gcc/tree-ssa-loop-ivopts.c (working copy)
@@ -7396,7 +7396,11 @@ rewrite_use_address (struct ivopts_data
base_hint = var_at_stmt (data->current_loop, cand, use->stmt);
iv = var_at_stmt (data->current_loop, cand, use->stmt);
- ref = create_mem_ref (&bsi, TREE_TYPE (*use->op_p), &aff,
+ tree type = TREE_TYPE (*use->op_p);
+ unsigned int align = get_object_alignment (*use->op_p);
+ if (align != TYPE_ALIGN (type))
+ type = build_aligned_type (type, align);
+ ref = create_mem_ref (&bsi, type, &aff,
reference_alias_ptr_type (*use->op_p),
iv, base_hint, data->speed);
copy_ref_info (ref, *use->op_p);