http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56643

             Bug #: 56643
           Summary: Failure to match noexcept specifier of friend template
                    function in template class
    Classification: Unclassified
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: s...@quanttec.com


The current SVN version of g++ fails to match the noexcept specifier of the
friend declaration and definition of the test template function in the
following code:

template <int N>
struct Test {
    template <int M>
    friend void test(Test<M>& arg) noexcept(M == 0);
};

template <int N>
void test(Test<N>& arg) noexcept(N == 0) {}

int main() {
    Test<0> t;
    test(t);
    return 0;
}

I get the following error:

g++ --std=c++11 test.cpp
test.cpp: In instantiation of ‘struct Test<0>’:
test.cpp:12:13:   required from here
test.cpp:5:17: error: declaration of ‘template<int M> void test(Test<N>&)
noexcept (<uninstantiated>)’ has a different exception specifier
     friend void test(Test<M>& arg) noexcept(M == 0);
                 ^
test.cpp:9:6: error: from previous declaration ‘template<int N> void
test(Test<N>&) noexcept ((N == 0))’
 void test(Test<N>& arg) noexcept(N == 0) {}
      ^

The error message seems to suggest that g++ confuses the template parameter of
the friend function declaration and the template parameter of the containing
class (note the 'N' in the line starting with 'test.cpp:5:17: error').

g++ 4.7.2 reports a similar error.

Reply via email to