public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56643] New: Failure to match noexcept specifier of friend template function in template class
@ 2013-03-17 20:02 st at quanttec dot com
2013-03-17 20:27 ` [Bug c++/56643] " paolo.carlini at oracle dot com
2014-07-24 20:08 ` Casey at Carter dot net
0 siblings, 2 replies; 3+ messages in thread
From: st at quanttec dot com @ 2013-03-17 20:02 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/56643] Failure to match noexcept specifier of friend template function in template class
2013-03-17 20:02 [Bug c++/56643] New: Failure to match noexcept specifier of friend template function in template class st at quanttec dot com
@ 2013-03-17 20:27 ` paolo.carlini at oracle dot com
2014-07-24 20:08 ` Casey at Carter dot net
1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-03-17 20:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56643
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-03-17
Version|4.7.3 |4.9.0
Ever Confirmed|0 |1
--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-03-17 20:27:02 UTC ---
Confirmed.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/56643] Failure to match noexcept specifier of friend template function in template class
2013-03-17 20:02 [Bug c++/56643] New: Failure to match noexcept specifier of friend template function in template class st at quanttec dot com
2013-03-17 20:27 ` [Bug c++/56643] " paolo.carlini at oracle dot com
@ 2014-07-24 20:08 ` Casey at Carter dot net
1 sibling, 0 replies; 3+ messages in thread
From: Casey at Carter dot net @ 2014-07-24 20:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56643
--- Comment #2 from Casey Carter <Casey at Carter dot net> ---
For future readers, I believe the simplest workaround is to make the friend
function a static member function of a new class, friend that class instead of
the function, and introduce a simple forwarding function in the original
function's place:
template <int N>
struct Test {
friend struct workaround_56643;
};
struct workaround_56643 {
template <int N>
static void test(Test<N>&) noexcept(N == 0) {}
};
template <int N>
auto test(Test<N>& arg)
noexcept(noexcept(workaround_56643::test(arg)))
-> decltype(workaround_56643::test(arg)) {
return workaround_56643::test(arg);
}
int main() {
Test<0> t;
test(t);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-24 20:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-17 20:02 [Bug c++/56643] New: Failure to match noexcept specifier of friend template function in template class st at quanttec dot com
2013-03-17 20:27 ` [Bug c++/56643] " paolo.carlini at oracle dot com
2014-07-24 20:08 ` Casey at Carter dot net
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).