This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Improve -Weffc++ item #11
- From: kaih at khms dot westfalen dot de (Kai Henningsen)
- To: gcc-patches at gcc dot gnu dot org
- Date: 08 Jul 2004 19:34:00 +0200
- Subject: Re: [C++ PATCH] Improve -Weffc++ item #11
- Comment: Unsolicited commercial mail will incur an US$100 handling fee per received mail.
- Organization: Organisation? Me?! Are you kidding?
- References: <066701c464e8$24808810$a54a2597@bagio>
giovannibajo@libero.it (Giovanni Bajo) wrote on 08.07.04 in <066701c464e8$24808810$a54a2597@bagio>:
> - We don't warn anymore if the class does not have a non-trivial destructor.
> * class.c (check_field_decls): Improve -Weffc++ warning: do not
> warn for pointers to functions/members, or for classes without
> destructors.
This does not match the actual patch:
> ! -- Warn only if there are members which are pointers
> ! -- Warn only if there is a non-trivial constructor (otherwise,
> ! there cannot be memory allocated).
> ! -- Warn only if there is a non-trivial destructor. We assume that the
> ! user at least implemented the cleanup correctly, and a destructor
> ! is needed to free dynamic memory.
> !
> ! This seems enough for pratical purposes. */
> ! if (warn_ecpp
> ! && has_pointers
> ! && TYPE_HAS_CONSTRUCTOR (t)
> ! && TYPE_HAS_DESTRUCTOR (t)
> ! && !(TYPE_HAS_INIT_REF (t) && TYPE_HAS_ASSIGN_REF (t)))
> {
> warning ("`%#T' has pointer data members", t);
This also tests for constructors. That seems wrong: a class can easily
hold dynamic memory that is only allocated on demand, which means it
doesn't necessarily need a non-trivial constructor.
MfG Kai