Commit ffc8b52f by Jakub Jelinek Committed by Jakub Jelinek

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
parent 724ad4a3
2018-03-15 Jakub Jelinek <jakub@redhat.com>
PR c++/79085
* calls.c (expand_call): For TREE_ADDRESSABLE rettype ignore alignment
check and use address of target always.
2018-03-15 H.J. Lu <hongjiu.lu@intel.com> 2018-03-15 H.J. Lu <hongjiu.lu@intel.com>
PR target/84574 PR target/84574
......
...@@ -3422,9 +3422,14 @@ expand_call (tree exp, rtx target, int ignore) ...@@ -3422,9 +3422,14 @@ expand_call (tree exp, rtx target, int ignore)
if (CALL_EXPR_RETURN_SLOT_OPT (exp) if (CALL_EXPR_RETURN_SLOT_OPT (exp)
&& target && target
&& MEM_P (target) && MEM_P (target)
&& !(MEM_ALIGN (target) < TYPE_ALIGN (rettype) /* If rettype is addressable, we may not create a temporary.
&& targetm.slow_unaligned_access (TYPE_MODE (rettype), If target is properly aligned at runtime and the compiler
MEM_ALIGN (target)))) 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); structure_value_addr = XEXP (target, 0);
else else
{ {
......
2018-03-15 Jakub Jelinek <jakub@redhat.com>
PR c++/79085
* g++.dg/opt/pr79085.C: New test.
2018-03-15 H.J. Lu <hongjiu.lu@intel.com> 2018-03-15 H.J. Lu <hongjiu.lu@intel.com>
PR target/84574 PR target/84574
......
// PR c++/79085
// { dg-do compile }
// { dg-options "-Os" }
// { dg-additional-options "-mstrict-align" { target { aarch64*-*-* powerpc*-*-linux* powerpc*-*-elf* } } }
void *operator new (__SIZE_TYPE__, void *p) { return p; }
struct S
{
S ();
S (const S &);
~S (void);
int i;
};
S foo ();
static char buf [sizeof (S) + 1];
S *
bar ()
{
return new (buf + 1) S (foo ());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment