My code:
const int N = 1048569;
struct A { };
struct B : virtual public A {
char space[N];
};
struct C : virtual public A {
void foo() {};
};
struct D : public B, public C { };
D T;
int main() {
T.foo();
return 0;
}
When I compile my code with -fsanitize=undefined, I got the runtime error below:
a.cpp:13:10: runtime error: member call on address 0x560aead1e6a8 which does not point to an object of type 'C'
0x560aead1e6a8: note: object has a possibly invalid vptr: abs(offset to top) too big
00 00 00 00 b0 dc c1 ea 0a 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^~~~~~~~~~~~~~~~~~~~~~~
possibly invalid vptr
The program run successfully if I don't use -fsanitize=undefined option.
What's more, if I set the value of N to 1048568 (just decrease by 1), the program runs successfully in both case.
I wonder if it's my fault or it's just because fsanitize cannot deal with such big size