Debian Codegraph @

gcc/testsuite/g++.dg/ubsan/pr69922.C

raw
1 // PR c++/69922
2 // { dg-do compile }
3 // { dg-options "-fsanitize=vptr -Wnonnull-compare" }
4
5 struct S { virtual ~S (); };
6 struct T : S { T *bar (); T *baz (); T *q; bool b; };
7
8 T *
9 T::bar ()
10 {
11 return static_cast<T*>(reinterpret_cast<S*>(this)); // { dg-bogus "nonnull argument" }
12 }
13
14 T *
15 T::baz ()
16 {
17 return static_cast<T*>(reinterpret_cast<S*>(b ? this : q)); // { dg-bogus "nonnull argument" }
18 }