aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2018-08-02 14:25:57 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2018-08-02 14:25:57 +0000
commitf70cb6f5b0ee51223319ec524994e59d356fb862 (patch)
treee9eae87de63873763871a755185272deb1e12bde /gcc
parent7c9f1147b866b3fec70fdce60bc37f1f4d41b330 (diff)
downloadgcc-f70cb6f5b0ee51223319ec524994e59d356fb862.zip
gcc-f70cb6f5b0ee51223319ec524994e59d356fb862.tar.gz
gcc-f70cb6f5b0ee51223319ec524994e59d356fb862.tar.bz2
re PR c++/86763 (Wrong code comparing member of copy of a 237 byte object with nontrivial default constructor on x86-64 arch)
2018-08-02 Richard Biener <rguenther@suse.de> PR c++/86763 * class.c (layout_class_type): Copy TYPE_TYPELESS_STORAGE to the CLASSTYPE_AS_BASE. * g++.dg/torture/pr86763.C: New testcase. From-SVN: r263261
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cp/class.c1
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr86763.C36
4 files changed, 48 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 85c1ef5..a406f8e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2018-08-02 Richard Biener <rguenther@suse.de>
+ PR c++/86763
+ * class.c (layout_class_type): Copy TYPE_TYPELESS_STORAGE
+ to the CLASSTYPE_AS_BASE.
+
+2018-08-02 Richard Biener <rguenther@suse.de>
+
PR tree-optimization/86816
* tree-ssa-tail-merge.c (tail_merge_valueize): New function
which checks for value availability before querying it.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index de59831..76a9e18 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -6279,6 +6279,7 @@ layout_class_type (tree t, tree *virtuals_p)
bitsize_int (BITS_PER_UNIT)));
SET_TYPE_ALIGN (base_t, rli->record_align);
TYPE_USER_ALIGN (base_t) = TYPE_USER_ALIGN (t);
+ TYPE_TYPELESS_STORAGE (base_t) = TYPE_TYPELESS_STORAGE (t);
/* Copy the non-static data members of T. This will include its
direct non-virtual bases & vtable. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b0e7505..976bfa8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2018-08-02 Richard Biener <rguenther@suse.de>
+ PR c++/86763
+ * g++.dg/torture/pr86763.C: New testcase.
+
+2018-08-02 Richard Biener <rguenther@suse.de>
+
PR tree-optimization/86816
* g++.dg/torture/pr86816.C: New testcase.
diff --git a/gcc/testsuite/g++.dg/torture/pr86763.C b/gcc/testsuite/g++.dg/torture/pr86763.C
new file mode 100644
index 0000000..6b79d56
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr86763.C
@@ -0,0 +1,36 @@
+// { dg-do run }
+// { dg-additional-options "-fschedule-insns2 -fstrict-aliasing" }
+
+#include <cstdint>
+#include <cassert>
+#include <time.h>
+struct ID {
+ uint64_t value;
+};
+uint64_t value(ID id) { return id.value; }
+uint64_t gen { 1000 };
+struct Msg {
+ uint64_t time;
+ ID id;
+};
+struct V {
+ V() { }
+ V(Msg const & msg) : msg(msg) { }
+ Msg & get() { return msg; }
+ Msg msg;
+ char pad[237 - sizeof(Msg)];
+};
+struct T : V { using V::V; };
+Msg init_msg() {
+ Msg msg;
+ timespec t;
+ clock_gettime(CLOCK_REALTIME, &t);
+ msg.time = t.tv_sec + t.tv_nsec;
+ msg.id.value = ++gen;
+ return msg;
+}
+int main() {
+ T t;
+ t = init_msg();
+ assert(value(t.get().id) == 1001);
+}