https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95221
Bug ID: 95221
Summary: g++.dg/ubsan/vptr-12.C fails with
-fstrong-eval-order=all
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
It's this code:
struct MyClass
{
virtual ~MyClass () {}
virtual void Doit () {}
};
int
main ()
{
MyClass *c = new MyClass;
c->~MyClass ();
c->Doit ();
return 0;
}
$ g++ vptr-12.C -fsanitize=vptr -fno-sanitize-recover=vptr
-fstrong-eval-order=some; ./a.out
vptr-12.C:16:11: runtime error: member call on address 0x000000a25eb0 which
does not point to an object of type 'MyClass'
0x000000a25eb0: note: object has invalid vptr
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 41 f1 00 00
^~~~~~~~~~~~~~~~~~~~~~~
invalid vptr
but
$ g++ vptr-12.C -fsanitize=vptr -fno-sanitize-recover=vptr
-fstrong-eval-order=all; ./a.out
Segmentation fault (core dumped)
This is important because C++17 implies -fstrong-eval-order=all.