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 * foo(B * b)11foo (B *b) 12 { 13 return static_cast<C *>(b); 14 } 15 16 __attribute__((noipa)) C * bar(B * b)17bar (B *b) 18 { 19 return &static_cast<C &>(*b); 20 } 21 22 __attribute__((noipa)) C * baz(B * b)23baz (B *b) 24 { 25 return &static_cast<C &>(*b); 26 } 27 28 int main()29main () 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 } 41