131
|
1 // PR c++/83555
|
|
2 // { dg-do run }
|
|
3 // { dg-options "-fsanitize=null" }
|
|
4 // { dg-output ":25:\[^\n\r]*reference binding to null pointer of type 'struct C'" }
|
|
5
|
|
6 struct A { int a; };
|
|
7 struct B { int b; };
|
|
8 struct C : A, B { int c; };
|
|
9
|
|
10 __attribute__((noipa)) C *
|
|
11 foo (B *b)
|
|
12 {
|
|
13 return static_cast<C *>(b);
|
|
14 }
|
|
15
|
|
16 __attribute__((noipa)) C *
|
|
17 bar (B *b)
|
|
18 {
|
|
19 return &static_cast<C &>(*b);
|
|
20 }
|
|
21
|
|
22 __attribute__((noipa)) C *
|
|
23 baz (B *b)
|
|
24 {
|
|
25 return &static_cast<C &>(*b);
|
|
26 }
|
|
27
|
|
28 int
|
|
29 main ()
|
|
30 {
|
|
31 C c;
|
|
32 if (foo (static_cast<B *> (&c)) != &c)
|
|
33 __builtin_abort ();
|
|
34 if (foo (0))
|
|
35 __builtin_abort ();
|
|
36 if (bar (static_cast<B *> (&c)) != &c)
|
|
37 __builtin_abort ();
|
|
38 baz (0);
|
|
39 return 0;
|
|
40 }
|