public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106940] New: Feature request: -Wsuggest-noexcept and -Wsuggest-explicit
@ 2022-09-14 8:56 felix.von.s at posteo dot de
2022-09-14 9:19 ` [Bug c++/106940] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: felix.von.s at posteo dot de @ 2022-09-14 8:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106940
Bug ID: 106940
Summary: Feature request: -Wsuggest-noexcept and
-Wsuggest-explicit
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: felix.von.s at posteo dot de
Target Milestone: ---
When writing classes, I routinely tend to forget that constructors can be used
for implicit conversions, unless marked explicit.
I also tend to forget about noexcept specifiers, which can lead to performance
pitfalls, especially with move constructors and move assignment operators.
So I would like a compiler warning that could remind me to consider such
concerns. In case of noexcept, I don’t particularly need full semantic
analysis of the body; a pure syntax check whether the specifier is present
should suffice. And in case of explicit, no other kind of check is possible,
obviously.
I imagine -Wsuggest-explicit could be suppressed for copy and move constructors
from the same type. I am undecided whether it should apply to conversion
operators, but leaning towards yes.
The warnings would be silenced by adding explicit specifiers: explicit(false)
and noexcept(false). Each warning should probably require the earliest
language version where the respective silencing is possible (C++20 and C++11,
respectively).
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/106940] Feature request: -Wsuggest-noexcept and -Wsuggest-explicit
2022-09-14 8:56 [Bug c++/106940] New: Feature request: -Wsuggest-noexcept and -Wsuggest-explicit felix.von.s at posteo dot de
@ 2022-09-14 9:19 ` redi at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-14 9:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106940
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |87403
Severity|normal |enhancement
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] 2+ messages in thread
end of thread, other threads:[~2022-09-14 9:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14 8:56 [Bug c++/106940] New: Feature request: -Wsuggest-noexcept and -Wsuggest-explicit felix.von.s at posteo dot de
2022-09-14 9:19 ` [Bug c++/106940] " 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).