From ffc8b52f9a5e73ad375be213ddcb1a8371dc328b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 15 Mar 2018 22:09:24 +0100 Subject: re PR c++/79085 (ICE with placement new to unaligned location) PR c++/79085 * calls.c (expand_call): For TREE_ADDRESSABLE rettype ignore alignment check and use address of target always. * g++.dg/opt/pr79085.C: New test. From-SVN: r258574 --- gcc/calls.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gcc/calls.c') diff --git a/gcc/calls.c b/gcc/calls.c index 19c95b8..4dcfef7 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -3422,9 +3422,14 @@ expand_call (tree exp, rtx target, int ignore) if (CALL_EXPR_RETURN_SLOT_OPT (exp) && target && MEM_P (target) - && !(MEM_ALIGN (target) < TYPE_ALIGN (rettype) - && targetm.slow_unaligned_access (TYPE_MODE (rettype), - MEM_ALIGN (target)))) + /* If rettype is addressable, we may not create a temporary. + If target is properly aligned at runtime and the compiler + just doesn't know about it, it will work fine, otherwise it + will be UB. */ + && (TREE_ADDRESSABLE (rettype) + || !(MEM_ALIGN (target) < TYPE_ALIGN (rettype) + && targetm.slow_unaligned_access (TYPE_MODE (rettype), + MEM_ALIGN (target))))) structure_value_addr = XEXP (target, 0); else { -- cgit v1.1