https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86233
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|unknown |9.0
Keywords| |diagnostic
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Ah, the issue is that GCC ignores the error if the original declaration is in a
system header:
# 1 "86233.C"
# 1 "inc.h" 1
# 2 "inc.h" 3
template<typename T> void f() noexcept { }
# 2 "86233.C" 2
# 2 "86233.C"
template<> void f<int>() { }
G++ gives a pedwarn with -Wsystem-headers:
86233.C:2:17: warning: declaration of 'void f() [with T = int]' has a different
exception specifier [-Wsystem-headers]
2 | template<> void f<int>() { }
| ^~~~~~
In file included from 86233.C:1:
inc.h:2:27: note: from previous declaration 'void f() noexcept [with T = int]'
2 | template<typename T> void f() noexcept { }
| ^
But this seems wrong, because the explicit specialization that has the wrong
exception spec is not in the system header. If user code defines an invalid
specialization of a template defined in a system header, that should not be
suppressed by default. The error is not in the system header.