This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Improve -Weffc++ item #11


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]