https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82311
Bug ID: 82311 Summary: prototype don't match Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: serge.guel...@telecom-bretagne.eu Target Milestone: --- The following code ``` template <class Arg> struct my_type { long fast(long i) const; long fast(long i) ; auto operator[](long i) const -> decltype(this->fast(i)); template <class E> auto fast(E const &expr) const -> decltype(expr.any()); }; template <class Arg> auto my_type<Arg>::operator[](long i) const -> decltype(this->fast(i)) { return fast(i); } ``` does not compile with gcc 7 $> g++ --version g++-7 (Debian 7.2.0-5) 7.2.0 The error message is the following bug.cc:15:6: error: prototype for ‘decltype (((const my_type<Arg>*)this)->my_type<Arg>::fast(i)) my_type<Arg>::operator auto my_type<Arg>::operator[](long i) const -> decltype(this->fast(i)) ^~~~~~~~~~~~ bug.cc:7:8: error: candidate is: decltype (((const my_type<Arg>*)this)->my_type<Arg>::fast(i)) my_type<Arg>::operator[] auto operator[](long i) const -> decltype(this->fast(i)); ^~~~~~~~ And surprisingly enough, swaping the two last declarations in the structure solve the issue.