https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88232

            Bug ID: 88232
           Summary: Please implement -Winfinite-recursion
           Product: gcc
           Version: 8.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rafael at espindo dot la
  Target Milestone: ---

This may sound like a silly warning, but it actually very useful in finding
missing member functions in CRTP. Given the testcase

template <typename D> struct C {
  void foo() { static_cast<D *>(this)->foo(); }
};
struct D : C<D> {
    // this is missing:
    // void foo() {}
};
void f(D *d) { d->foo(); }

gcc is silent, but clang prints:

test.cpp:2:14: warning: all paths through this function will call itself
[-Winfinite-recursion]
  void foo() { static_cast<D *>(this)->foo(); }

Reply via email to