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


On Tuesday, 7. February 2006 22:44, Mark Mitchell wrote:

> It's been a long time since I've read the book, but to me the point of
> the rule is that constructors are for initializing things

I agree. However the warning only triggers if a member isn't listed in the 
initialisation list, even if it is later initialized in the constructor body. 
And if you initialize in the constructor body or in the initialisation list 
does not make the slightest difference for pointers or similiar. Therefore I 
consider

foo::foo()
{
    m_p = new Bla;
}

more readable than

foo::foo()
   : m_p(new Bla)
{
}

Especially if complicated if() or while/for loops (nested arrays?) are needed 
to do the proper construction. I haven't seen a way to do a nested array 
construction in an initializer list. Therefore, as there are legitimate 
cases, gcc should shut up. IMHO. 

Anyway, I see there is a policy difference: To me, the -Weffc++ warnings 
shouldn't be on-the-letter-from-the-book, but in the spirit of the book. And 
currently those warnings are pretty unsuable, produce 3-4 pages of "false 
positives" for nontrivial projects. While all those warnings (missing copy 
constructor, missing initializer) are extremely useful in theory. Just given 
that they currently vomit millions of "uninteresting" cases, its even more 
difficult to find the one legitimate warning inside that spill of output. 

(And this is only the first of a probably long series of fixups that still 
have to be done). 


Dirk


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