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: [PATCH c++] Reduce -Weffc++ Rule 12 false positives


Dirk Mueller <dmueller@suse.de> writes:

| On Tuesday, 7. February 2006 22:33, Gabriel Dos Reis wrote:
| 
| > I don't understand.  Actually, we should be warning for those cases,
| > especially I don't understand this:
| 
| Well, the point of the rule is that if you have member that is of class-type, 
| not listing it in the initializer list will make the compiler emit code to 
| call the default constructor.

Good, that is what constructors are for.

| If you then later copy-assign (or via other 
| means) initialize the member in the constructor body, you actually did the 
| initialisation twice, wasting CPU cycles and code size.

I don't really believe that that is the point of the guideline.  The rule is
t have people initialize things.  If you have a default constructor
that leaves some members uninitialized, that is asking for trouble.

-- Gaby


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