diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/ubsan/vptr-5.C')
-rw-r--r-- | gcc/testsuite/g++.dg/ubsan/vptr-5.C | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/ubsan/vptr-5.C b/gcc/testsuite/g++.dg/ubsan/vptr-5.C new file mode 100644 index 0000000000..fb9d15cc99 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/vptr-5.C @@ -0,0 +1,32 @@ +// { dg-do run } +// { dg-options "-fsanitize=vptr" } + +struct S +{ + S() : a(0) {} + ~S() {} + int a; + int f() { return 0; } + virtual int v() { return 0; } +}; + +struct T : S +{ + T() : b(0) {} + int b; + int g() { return 0; } + virtual int v() { return 1; } +}; + +T * +foo (S *p) +{ + return (T *) p; +} + +int +main () +{ + if (foo (__null) != __null) + __builtin_abort (); +} |