https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86652
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-07-24
Ever confirmed|0 |1
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> This seems like the const is applying to the function (not the function type
> that it is returning).
Indeed:
struct C {
template <typename> int (*f())() const;
};
int main()
{
const C c;
auto f = c.f<int>();
return f == nullptr;
}
c.cc: In function 'int main()':
c.cc:9:21: error: passing 'const C' as 'this' argument discards qualifiers
[-fpermissive]
auto f = c.f<int>();
^
c.cc:3:29: note: in call to 'int (* C::f())() [with <template-parameter-1-1>
= int]'
template <typename> int (*f())() const;
^
That would be correct given:
template <typename> int (*f() const)();
so g++ is parsing the declarator incorrectly.