public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94112] New: Please add a warning for potentially throwing code in noexcept function
@ 2020-03-10 1:09 rafael at espindo dot la
2020-03-10 15:34 ` [Bug c++/94112] " msebor at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: rafael at espindo dot la @ 2020-03-10 1:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94112
Bug ID: 94112
Summary: Please add a warning for potentially throwing code in
noexcept function
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: rafael at espindo dot la
Target Milestone: ---
GCC produces a warning for
void foo() noexcept {
throw 42;
}
But not for
static void bar() {
throw 42;
}
void foo() noexcept {
bar();
}
Such a warning would be quite handy for checking the usage of noexcept in a
codebase.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/94112] Please add a warning for potentially throwing code in noexcept function
2020-03-10 1:09 [Bug c++/94112] New: Please add a warning for potentially throwing code in noexcept function rafael at espindo dot la
@ 2020-03-10 15:34 ` msebor at gcc dot gnu.org
2020-03-10 15:53 ` rafael at espindo dot la
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-03-10 15:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94112
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2020-03-10
CC| |msebor at gcc dot gnu.org
Blocks| |87403
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed with the output below. -Wterminate is fully implemented in the C++
front-end so it doesn't know about what might happen in called functions.
Implementing the detection across inlined functions requires moving the warning
to the middle-end and deciding how to deal with situations where the called
function throws only under some non-constant conditions (e.g., issue
-Wterminate regardless, or a -Wmaybe-terminate kind of a warning, or none).
$ gcc -O2 -Wall -Wextra -S -Wall a.C
void foo () noexcept
{
throw 42;
}
static void bar ()
{
throw 42;
}
void foobar () noexcept
{
bar ();
}
a.C: In function ‘void foo()’:
a.C:3:5: warning: ‘throw’ will always call ‘terminate’ [-Wterminate]
3 | throw 42;
| ^~~~~~~~
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403
[Bug 87403] [Meta-bug] Issues that suggest a new warning
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/94112] Please add a warning for potentially throwing code in noexcept function
2020-03-10 1:09 [Bug c++/94112] New: Please add a warning for potentially throwing code in noexcept function rafael at espindo dot la
2020-03-10 15:34 ` [Bug c++/94112] " msebor at gcc dot gnu.org
@ 2020-03-10 15:53 ` rafael at espindo dot la
2020-03-10 16:01 ` redi at gcc dot gnu.org
2021-10-27 5:17 ` egallager at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rafael at espindo dot la @ 2020-03-10 15:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94112
--- Comment #2 from Rafael Avila de Espindola <rafael at espindo dot la> ---
(In reply to Martin Sebor from comment #1)
> Confirmed with the output below. -Wterminate is fully implemented in the
> C++ front-end so it doesn't know about what might happen in called
> functions. Implementing the detection across inlined functions requires
> moving the warning to the middle-end and deciding how to deal with
> situations where the called function throws only under some non-constant
> conditions (e.g., issue -Wterminate regardless, or a -Wmaybe-terminate kind
> of a warning, or none).
I would be happy even with a "noexcept function calls a non-noexcept one"
warning.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/94112] Please add a warning for potentially throwing code in noexcept function
2020-03-10 1:09 [Bug c++/94112] New: Please add a warning for potentially throwing code in noexcept function rafael at espindo dot la
2020-03-10 15:34 ` [Bug c++/94112] " msebor at gcc dot gnu.org
2020-03-10 15:53 ` rafael at espindo dot la
@ 2020-03-10 16:01 ` redi at gcc dot gnu.org
2021-10-27 5:17 ` egallager at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2020-03-10 16:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94112
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
That would likely be far too noisy for use 99% of the time.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/94112] Please add a warning for potentially throwing code in noexcept function
2020-03-10 1:09 [Bug c++/94112] New: Please add a warning for potentially throwing code in noexcept function rafael at espindo dot la
` (2 preceding siblings ...)
2020-03-10 16:01 ` redi at gcc dot gnu.org
@ 2021-10-27 5:17 ` egallager at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-10-27 5:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94112
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |egallager at gcc dot gnu.org
Resolution|--- |DUPLICATE
Status|NEW |RESOLVED
--- Comment #4 from Eric Gallager <egallager at gcc dot gnu.org> ---
dup of bug 61372
*** This bug has been marked as a duplicate of bug 61372 ***
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-10-27 5:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10 1:09 [Bug c++/94112] New: Please add a warning for potentially throwing code in noexcept function rafael at espindo dot la
2020-03-10 15:34 ` [Bug c++/94112] " msebor at gcc dot gnu.org
2020-03-10 15:53 ` rafael at espindo dot la
2020-03-10 16:01 ` redi at gcc dot gnu.org
2021-10-27 5:17 ` egallager 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).