UB-sanitizer reports a runtime error for the following program:
```
struct B;
struct I {
virtual void f() {}; // <- virtual
};
struct A : I {
A();
};
struct B : A {
};
A::A() { *static_cast<B*>(this); } // <- UB in static_cast
int main()
{
B{};
}
```
My question: is UB-sanitizer correct? Is this a UB according to the standard? And if so, could you point me to the relevant sections?
Some people point out that pointer dereference means accessing the (not yet constructed) object, but according to my reading referring to an object is not access. And also, UB sanitizer reports an UB when there is no dereference:
```
struct B;
struct I {
virtual void f() {}; // <- virtual
};
struct A : I {
A();
};
struct B : A {
};
A::A() { static_cast<B*>(this); } // <- No dereference
int main()
{
B{};
}
```
Is this second example a UB also?
Regards,
&rzej;