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 Wednesday, 8. February 2006 00:46, Gabriel Dos Reis wrote:
| 
| > The only odd about it is the warning about "B::right".
| 
| You can suppress that one by reformatting your code: 

I agree, but this reformat

| struct B
| {
|   B() : right() { bogus = 42; }
|   int bogus;
|   A right;
| }

is the wrong one.

The "minimum" is this:

 struct B
 {
   B() : bogus(42) { }
   int bogus;
   A right;
 }

and if you want to be picky about Item 12, then it would be 

 struct B
 {
   B() : bogus(42), right() { }
   int bogus;
   A right;
 }

[...]

| But if that is more maintainable is questionable. It also depends on if imply 
| an ordering of construction in your initializer list. Most code I've seen 
| puts the stuff that doesn't depend on construction order in the initializer 
| list, and the other one (that possibly even depends on allocations and oder 
| complicated decisions) in the constructor body. 

Most codes I've seen have been misled by ill-implementations of the
guidelines (we had that repeatedly in our own libstdc++ code, and they had
to be taken out), and blind interpretation of the rules.  For most
part, people seem to tinker with the constructors until the compiler is silent
without perspective.  With the consequence that bugs are hidden
and harder to find.  I do think the version of the patch you sent
worsen the situation.

[...]

| > Yes, the current implementation is not perfect and makes lot of noise,
| > but your proposed patch retains the worst noise and shut up the useful
| > ones.
| 
| Depends on if you care about performance overhead due to unnecessary calls to 
I do, and I've been on the record for that -- check the archive if you
had a doubt :-)

-- Gaby


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