From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B4A903858418; Sat, 5 Nov 2022 09:12:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4A903858418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667639560; bh=Eu3cSI7tROEKVaRlZMpD0THtfMyjXrHBAvdrwvDskvY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nCvQCVt02fQ1fzHJtA+i+kBPS7++feNbI7VJsDwv6Xj1QFwt/narR+gH04okN+mIq iAMX5+zziHu5kHIGwn+8ClDT7f43m4ie3aKDUBV2KbvxpG+1T2cWnml+JjWNQqXpnF CUWiK5G8zQuCakpjdEk+kbv3j8IGtAKK1rwCkz1Y= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107531] List of references calls destructors, add warning? Date: Sat, 05 Nov 2022 09:12:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: WORKSFORME X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107531 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |WORKSFORME --- Comment #3 from Jonathan Wakely --- Why should the compiler warn here? There are no resources being freed. Maki= ng trivial copies and then destroying them is not a bug. If you give the class some resources to manage (e.g. a pointer member) then -Weffc++ will warn that you messed up: dest.C:2:8: warning: =E2=80=98struct S=E2=80=99 has pointer data members [-= Weffc++] 2 | struct S { | ^ dest.C:2:8: warning: but does not declare =E2=80=98S(const S&)=E2=80=99 [= -Weffc++] dest.C:2:8: warning: or =E2=80=98operator=3D(const S&)=E2=80=99 [-Weffc++] dest.C:5:10: note: pointer member =E2=80=98S::p=E2=80=99 declared here 5 | int* p =3D nullptr; | ^ It would be nice if you could turn on this warning without the rest of -Wef= fc++ but that's PR 16166.=