summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ubsan/pr65019.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/ubsan/pr65019.C')
-rw-r--r--gcc/testsuite/g++.dg/ubsan/pr65019.C24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/ubsan/pr65019.C b/gcc/testsuite/g++.dg/ubsan/pr65019.C
new file mode 100644
index 0000000000..a7f21a7d24
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ubsan/pr65019.C
@@ -0,0 +1,24 @@
+// PR sanitizer/65019
+// { dg-do compile }
+// { dg-options "-fsanitize=alignment,object-size,vptr -std=c++11 -O2 -fcompare-debug" }
+
+struct A { };
+struct B { };
+struct C final {
+ C (const A &, int);
+ static B *foo (const A &, int = 1);
+ virtual ~C ();
+ void *c;
+};
+
+B *
+C::foo (const A &x, int y)
+{
+ C *d = new C (x, y);
+ if (d->c == nullptr)
+ delete d;
+}
+
+C::~C ()
+{
+}