This is the mail archive of the gcc@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]

Effective C++


> OK.  Last time I looked Checker was not ready for mainstream C++ use.
> Time to look again, I guess.

Well, I didn't say that Checker actually works. If you want to extend
g++, your efforts would be much better spend on that functionality,
IMHO.

> In my style, constructors assign default values to non-aggegrates
> and do nothing funky.  Occasionally I add a new data member, and
> forget to add an initializer.  I would like to catch that case; it
> seemed to me like a reasonable extension of -Wuninitialized

You are certainly entitled to your own coding style, but I guess many
C++ programmers disagree that constructors should only do
copy-initialization in their body. A certain fraction of C++ users
will even disagree that using assignments is a good style to
initialization in constructors (including, apparently, Scott Meyers,
and yours, truly).

> It does not prevent me from forgetting to add an initialization, and
> using -Weffc++ in conjunction with the library is a PITA.  Besides, I
> do not want to.  I think that that style of coding is unreadable, and
> just another example of the brokenness of C++.

I think that the readability is a formatting issue. On the factual
side, initialization in the body of the ctor:
- - is not exception-safe,
- - might result in performance costs, in case members already performed
  some default initialization,
- - does not work for members with no default ctor, and
- - cannot be as easily tested (which was the origin of the discussion).

I agree that this is not the place for a flame-war. All I'm saying is
that I see no use for the feature you proposed.

Regards,
Martin


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