This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/77367] New: Duck-typing error not detected when using CRTP
- From: "yuhang_tang at brown dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 24 Aug 2016 13:35:49 +0000
- Subject: [Bug c++/77367] New: Duck-typing error not detected when using CRTP
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77367
Bug ID: 77367
Summary: Duck-typing error not detected when using CRTP
Product: gcc
Version: 6.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: yuhang_tang at brown dot edu
Target Milestone: ---
The following code was able to pass compilation & linking, yet the Derived::B()
function is not defined. Since the cast is static I would expect that the
compiler could find that there is not a definition of
static_cast<Derived&>(*this).B() and raise an error.
template<class Derived>
struct Base {
void A() { static_cast<Derived&>(*this).A(); }
void B() { static_cast<Derived&>(*this).B(); }
};
struct Derived : Base<Derived> {
void A() {}
//void B() {}
};
int main() {
Derived d;
Base<Derived> &b = d;
b.A();
b.B();
}
This resulted in the compiled binary hanging forever in Fedora 24 Kernel 4.6.5.