This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/82311] New: prototype don't match
- From: "serge dot guelton at telecom-bretagne dot eu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 23 Sep 2017 20:46:59 +0000
- Subject: [Bug c++/82311] New: prototype don't match
- Auto-submitted: auto-generated
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.guelton@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.