[Bug c++/59766] c++1y: declaring friend function with 'auto' return type deduction is rejected with bogus reason

potswa at mac dot com gcc-bugzilla@gcc.gnu.org
Fri Jan 23 09:44:00 GMT 2015


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

--- Comment #6 from David Krauss <potswa at mac dot com> ---
Created attachment 34541
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34541&action=edit
Fix: disable the error for friend declarators.

The fix is simple. Tested and submitted for approval. (I am a registered
contributor.)

I don't suppose this warrants a testcase file. If you want to exercise the
compiler, here is a more interesting case:


template< typename k >
struct t {
    friend auto leak( t );

    template< typename v >
    struct m {
        friend auto leak( t ) { return v{}; }
    };
};

int main() {
    t< int >::m< char > a;
    decltype( leak( t< int >{} ) ) b;
    static_assert ( sizeof b == 1, "" );

    t< int >::m< short > c; // error: redefinition of ‘auto leak(t<int>)’
}


More information about the Gcc-bugs mailing list