public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/88050] Add a warning for breaking the "Rule of Three"
       [not found] <bug-88050-4@http.gcc.gnu.org/bugzilla/>
@ 2022-02-10  9:14 ` felix.von.s at posteo dot de
  0 siblings, 0 replies; only message in thread
From: felix.von.s at posteo dot de @ 2022-02-10  9:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88050

felix <felix.von.s at posteo dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |felix.von.s at posteo dot de

--- Comment #4 from felix <felix.von.s at posteo dot de> ---
Created attachment 52401
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52401&action=edit
Basic patch (no tests)

Attached is a simple patch adding a warning checks for violations of the Rule
of Three and the Rule of Five (Core Guideline C.21) and enabling it at the
-Wextra level.

Not included is a check for the rule-of-four-and-a-half variant: a swapping
by-value assignment operator overload, paired with the appropriate constructor,
is enough to implement copy- or move-assignment.

Rule of Zero would be much harder to check for, but it may be possible to
diagnose certain violations of it, by looking at the code inside the
destructor: if the delete operator, or a single function is invoked more than
once in the destructor, it probably means the class manages more than one
resource.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-02-10  9:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-88050-4@http.gcc.gnu.org/bugzilla/>
2022-02-10  9:14 ` [Bug c++/88050] Add a warning for breaking the "Rule of Three" felix.von.s at posteo dot de

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).