Hi everyone,
The following is a code from a test in the Clang Static Analyzer (clang/test/Analysis/pointer-to-member.cpp): Why are the last two statements expected to produce a warning?
struct B {
int f;
};
struct L1 : public B { };
struct R1 : public B { };
struct M : public L1, R1 { };
struct L2 : public M { };
struct R2 : public M { };
struct D2 : public L2, R2 { };
void diamond() {
M m;
static_cast<L1 *>(&m)->f = 7;
static_cast<R1 *>(&m)->f = 16;
int L1::* pl1 = &B::f;
int M::* pm_via_l1 = pl1;
int R1::* pr1 = &B::f;
int M::* pm_via_r1 = pr1;
clang_analyzer_eval(m.(pm_via_l1) == 7); // expected-warning {{TRUE}}
clang_analyzer_eval(m.(pm_via_r1) == 16); // expected-warning {{TRUE}}
}
Warm Regards,
Deep