2018-06-25 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 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-09 Jakub Jelinek <jakub@redhat.com>
PR target/84772
if (CALL_EXPR_RETURN_SLOT_OPT (exp)
&& target
&& MEM_P (target)
- && !(MEM_ALIGN (target) < TYPE_ALIGN (rettype)
- && 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)
+ && SLOW_UNALIGNED_ACCESS (TYPE_MODE (rettype),
+ MEM_ALIGN (target)))))
structure_value_addr = XEXP (target, 0);
else
{
Backported from mainline
2018-03-15 Jakub Jelinek <jakub@redhat.com>
+ PR c++/79085
+ * g++.dg/opt/pr79085.C: New test.
+
PR c++/84222
* g++.dg/warn/deprecated.C (T::member3): Change dg-warning to dg-bogus.
* g++.dg/warn/deprecated-6.C (T::member3): Likewise.
--- /dev/null
+// 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 ());
+}