This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/56643] New: Failure to match noexcept specifier of friend template function in template class


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: unassigned@gcc.gnu.org
        ReportedBy: st@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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]