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

            Bug ID: 98441
           Summary: member function pointer incorrectly parsed as having
                    trailing return type
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: daniel.santos at pobox dot com
  Target Milestone: ---

When declaring pointer to a member function pointer using atuo& as the
function's return type, we get a bad parse:

struct a {
    int& mfn();
};

void fn()
{
    int&  (a::*myvar1)(void) = &a::mfn;
    auto& (a::*myvar2)(void) = &a::mfn;
    auto  (a::*myvar3)(void) = &a::mfn;
}

Results in:

<source>: In function 'void fn()':
<source>:8:5: error: 'myvar2' function with trailing return type has 'auto&' as
its type rather than plain 'auto'
    8 |     auto& (a::*myvar2)(void) = &a::mfn;
      |     ^~~~

However, it builds on GCC 9 and is alleged to build on MSVC.  The above example
is simplified from the original sources:

https://github.com/freeorion/freeorion/blob/v0.4.10.1/python/UniverseWrapper.cpp#L193

Reply via email to