Commit f70cb6f5 by Richard Biener Committed by Richard Biener

re PR c++/86763 (Wrong code comparing member of copy of a 237 byte object with…

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
parent 7c9f1147
2018-08-02 Richard Biener <rguenther@suse.de> 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 PR tree-optimization/86816
* tree-ssa-tail-merge.c (tail_merge_valueize): New function * tree-ssa-tail-merge.c (tail_merge_valueize): New function
which checks for value availability before querying it. which checks for value availability before querying it.
......
...@@ -6279,6 +6279,7 @@ layout_class_type (tree t, tree *virtuals_p) ...@@ -6279,6 +6279,7 @@ layout_class_type (tree t, tree *virtuals_p)
bitsize_int (BITS_PER_UNIT))); bitsize_int (BITS_PER_UNIT)));
SET_TYPE_ALIGN (base_t, rli->record_align); SET_TYPE_ALIGN (base_t, rli->record_align);
TYPE_USER_ALIGN (base_t) = TYPE_USER_ALIGN (t); 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 /* Copy the non-static data members of T. This will include its
direct non-virtual bases & vtable. */ direct non-virtual bases & vtable. */
......
2018-08-02 Richard Biener <rguenther@suse.de> 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 PR tree-optimization/86816
* g++.dg/torture/pr86816.C: New testcase. * g++.dg/torture/pr86816.C: New testcase.
......
// { 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);
}
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