This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Effective C++
- To: egcs at egcs dot cygnus dot com
- Subject: Effective C++
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Wed, 9 Jun 1999 21:33:49 +0200
- References: <14174.17024.308218.207820@dokkum.cs.uu.nl>
> 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