public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/86233] explicit specialization of function template accepted with weaker exception specification
[not found] <bug-86233-4@http.gcc.gnu.org/bugzilla/>
@ 2021-08-23 9:25 ` pinskia at gcc dot gnu.org
2021-08-23 10:53 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-23 9:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86233
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Now the reduced testcases are rejected for always.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/86233] explicit specialization of function template accepted with weaker exception specification
[not found] <bug-86233-4@http.gcc.gnu.org/bugzilla/>
2021-08-23 9:25 ` [Bug c++/86233] explicit specialization of function template accepted with weaker exception specification pinskia at gcc dot gnu.org
@ 2021-08-23 10:53 ` redi at gcc dot gnu.org
2021-08-23 10:58 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-23 10:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86233
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> Now the reduced testcases are rejected for always.
I think they always were rejected by G++, so they were bad reductions.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/86233] explicit specialization of function template accepted with weaker exception specification
[not found] <bug-86233-4@http.gcc.gnu.org/bugzilla/>
2021-08-23 9:25 ` [Bug c++/86233] explicit specialization of function template accepted with weaker exception specification pinskia at gcc dot gnu.org
2021-08-23 10:53 ` redi at gcc dot gnu.org
@ 2021-08-23 10:58 ` redi at gcc dot gnu.org
2021-08-23 11:01 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-23 10:58 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/86233] explicit specialization of function template accepted with weaker exception specification
[not found] <bug-86233-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2021-08-23 10:58 ` redi at gcc dot gnu.org
@ 2021-08-23 11:01 ` redi at gcc dot gnu.org
2021-08-23 11:08 ` redi at gcc dot gnu.org
2021-08-23 11:10 ` redi at gcc dot gnu.org
5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-23 11:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86233
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
>From cp/decl.c:check_redeclaration_exception_specification
/* [except.spec]
If any declaration of a function has an exception-specification,
all declarations, including the definition and an explicit
specialization, of that function shall have an
exception-specification with the same set of type-ids. */
if (!DECL_IS_UNDECLARED_BUILTIN (old_decl)
&& !DECL_IS_UNDECLARED_BUILTIN (new_decl)
&& !comp_except_specs (new_exceptions, old_exceptions, ce_normal))
{
const char *const msg
= G_("declaration of %qF has a different exception specifier");
bool complained = true;
location_t new_loc = DECL_SOURCE_LOCATION (new_decl);
auto_diagnostic_group d;
if (DECL_IN_SYSTEM_HEADER (old_decl))
complained = pedwarn (new_loc, OPT_Wsystem_headers, msg, new_decl);
else if (!flag_exceptions)
/* We used to silently permit mismatched eh specs with
-fno-exceptions, so make them a pedwarn now. */
complained = pedwarn (new_loc, OPT_Wpedantic, msg, new_decl);
else
error_at (new_loc, msg, new_decl);
if (complained)
inform (DECL_SOURCE_LOCATION (old_decl),
"from previous declaration %qF", old_decl);
}
The DECL_IN_SYSTEM_HEADER check seems wrong. I think it should be checking
new_decl instead.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/86233] explicit specialization of function template accepted with weaker exception specification
[not found] <bug-86233-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2021-08-23 11:01 ` redi at gcc dot gnu.org
@ 2021-08-23 11:08 ` redi at gcc dot gnu.org
2021-08-23 11:10 ` redi at gcc dot gnu.org
5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-23 11:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86233
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The code was changed by r223778 to depend on -Wsystem-headers instead of
-Wpedantic, and the testcase for that commit suggests the current behaviour is
by design. But that testcase uses a redeclaration of a standard function:
#include <stdlib.h>
extern double atof (const char *);
That seems substantially different to an explicit specialization of a function
template, which is not just a redeclaration. Maybe we want a completely
different rule for template specializations.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/86233] explicit specialization of function template accepted with weaker exception specification
[not found] <bug-86233-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2021-08-23 11:08 ` redi at gcc dot gnu.org
@ 2021-08-23 11:10 ` redi at gcc dot gnu.org
5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-23 11:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86233
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The check was originally added by r106884 for PR c++/24817
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-08-23 11:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-86233-4@http.gcc.gnu.org/bugzilla/>
2021-08-23 9:25 ` [Bug c++/86233] explicit specialization of function template accepted with weaker exception specification pinskia at gcc dot gnu.org
2021-08-23 10:53 ` redi at gcc dot gnu.org
2021-08-23 10:58 ` redi at gcc dot gnu.org
2021-08-23 11:01 ` redi at gcc dot gnu.org
2021-08-23 11:08 ` redi at gcc dot gnu.org
2021-08-23 11:10 ` redi at gcc dot gnu.org
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).