[Bug c++/79085] [6/7/8 Regression] ICE with placement new to unaligned location
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 15 14:22:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79085
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
Target Milestone|--- |6.5
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started to ICE with r232167, before that it has been just silent wrong-code,
calling the function/method with a temporary and then copying it over (and not
destructing) despite perhaps having non-trivial copy ctor and/or dtor.
Untested fix:
--- gcc/calls.c.jj 2018-02-22 12:37:02.641387687 +0100
+++ gcc/calls.c 2018-03-15 15:17:42.596835316 +0100
@@ -3422,9 +3422,14 @@ expand_call (tree exp, rtx target, int i
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
{
More information about the Gcc-bugs
mailing list