comparison gcc/testsuite/g++.dg/torture/pr78189.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* { dg-do run } */
2 /* { dg-additional-options "-ftree-slp-vectorize -fno-vect-cost-model" } */
3
4 #include <cstddef>
5
6 struct A
7 {
8 void * a;
9 void * b;
10 };
11
12 struct alignas(16) B
13 {
14 void * pad;
15 void * misaligned;
16 void * pad2;
17
18 A a;
19
20 void Null();
21 };
22
23 void B::Null()
24 {
25 a.a = nullptr;
26 a.b = nullptr;
27 }
28
29 void __attribute__((noinline,noclone))
30 NullB(void * misalignedPtr)
31 {
32 B* b = reinterpret_cast<B*>(reinterpret_cast<char *>(misalignedPtr) - offsetof(B, misaligned));
33 b->Null();
34 }
35
36 int main()
37 {
38 B b;
39 NullB(&b.misaligned);
40 return 0;
41 }