mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
C++: Respond to review comments.
This commit is contained in:
@@ -4,47 +4,47 @@ struct B;
|
||||
void call_f(B*);
|
||||
|
||||
struct B : public A {
|
||||
B() {
|
||||
call_f(this);
|
||||
}
|
||||
B() {
|
||||
call_f(this);
|
||||
}
|
||||
|
||||
B(B& b) {
|
||||
b.f(); // BAD: undefined behavior
|
||||
}
|
||||
B(B& b) {
|
||||
b.f(); // BAD: undefined behavior
|
||||
}
|
||||
|
||||
~B() {
|
||||
f(); // BAD: undefined behavior
|
||||
}
|
||||
~B() {
|
||||
f(); // BAD: undefined behavior
|
||||
}
|
||||
};
|
||||
|
||||
struct C : public B {
|
||||
C(bool b) {
|
||||
call_f(this);
|
||||
C(bool b) {
|
||||
call_f(this);
|
||||
|
||||
if(b) {
|
||||
this->f(); // GOOD: Not a 'must' flow
|
||||
}
|
||||
}
|
||||
if(b) {
|
||||
this->f(); // GOOD: Not a 'must' flow
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct D : public B {
|
||||
D() : B(*this) {}
|
||||
D() : B(*this) {}
|
||||
};
|
||||
|
||||
void call_f(B* x) {
|
||||
x->f(); // 2 x BAD: Undefined behavior
|
||||
x->f(); // 2 x BAD: Undefined behavior
|
||||
}
|
||||
|
||||
struct E : public A {
|
||||
E() {
|
||||
f(); // GOOD: Will call `E::f`
|
||||
}
|
||||
E() {
|
||||
f(); // GOOD: Will call `E::f`
|
||||
}
|
||||
|
||||
void f() override {}
|
||||
void f() override {}
|
||||
};
|
||||
|
||||
struct F : public E {
|
||||
F() {
|
||||
((A*)this)->f(); // BAD: undefined behavior
|
||||
}
|
||||
F() {
|
||||
((A*)this)->f(); // BAD: undefined behavior
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user