Date: Sun, 12 May 2019 17:54:26 +0200
consider the following (also on https://gcc.godbolt.org/z/6ikNyq):
structS; // (1)
structU {
S* sp_;
U(S* sp) : sp_{sp} {}
autop() -> int;
};
structB {
inti_ = 42;
autop(inta) -> int{ returna + i_; }
};
structS : B { // (2) Type S is completed here ... legal to introduce B
as base?
autop() -> int{ returnB::p(3); }
};
autoU::p() -> int{ returnsp_->p(); }
intmain() {
S s{};
U u{&s};
returnu.p();
}
Is this legal? Reading the standard I do not find anything that either
forbids it, but neither do I find anything that allows it.
All compilers that I tried are fine with it, but does anyone know
whether this is intentional?
structS; // (1)
structU {
S* sp_;
U(S* sp) : sp_{sp} {}
autop() -> int;
};
structB {
inti_ = 42;
autop(inta) -> int{ returna + i_; }
};
structS : B { // (2) Type S is completed here ... legal to introduce B
as base?
autop() -> int{ returnB::p(3); }
};
autoU::p() -> int{ returnsp_->p(); }
intmain() {
S s{};
U u{&s};
returnu.p();
}
Is this legal? Reading the standard I do not find anything that either
forbids it, but neither do I find anything that allows it.
All compilers that I tried are fine with it, but does anyone know
whether this is intentional?
Received on 2019-05-12 10:56:34