This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Request for a C++ warning for undefined behaviour
skaller <skaller@ozemail.com.au> writes:
| On Wed, 2003-08-13 at 22:22, Gabriel Dos Reis wrote:
| > skaller <skaller@ozemail.com.au> writes:
|
| > | No, I don't agree. It is certainly possible to be coding
| > | in a good style and make an honest mistake.
| >
| > "honest mistake" is meaningless.
|
| It means "you were trying to do the right thing,
| but typed something wrong by accident".
|
| rather than:
|
| "you are using a practice which is known
| to be fraught with errors"
Well, initialization within the member-initalizer list is taught to be
good style; and initialization within the constructor body is also
"known fraught with errors".
| There really is something called "good design"
| and "bad design" even though it isn't so easy
| to say exactly what it is in most cases.
Yes.
[...]
| > | Nope, I'd never use a ctor-initialiser to initialise a variable
| > | or base other than with a parameter to the constructor, or, at worst,
| > | a component of a structure.
| >
| > But not every member is default constructed.
|
| So what? If the member isn't default constructed,
| AND i need to do a calculation to initialise it,
| there is a design error somewhere in there.
I don't think that necessary follows. I would say that there is a
design error -depending- on the kind of calculations that need to be
carried out. Not just because there is a calculation.
| > You have a particular
| > coding style. Fine. But I see no reason to force people to follow
| > one signle style. In particular, initializing member in the
| > member-initializer-list does make sense.
|
| Of course it does. Initialising it with a complex
| expression, however, is just bad coding practice,
| or, if it seems necessary, bad design.
That is different from previous assertions of yours. And I can be
made to agree with the new formulation.
|
| > Of course, if you put in
| > gardage, you get garbage out. Matt was asking for a flag that would
| > assist him to detect when a garbage is inadvertently being put in.
|
| >From the example I conclude otherwise. I conclude Michael
| is asking for the flag to help detect garbage within garbage
| which was *deliberately* put in, and my reaction is:
We have no evidence that the garbage was deliberately being put in.
That can come from ignorance also.
| it hardly seems worthwhile trying to help people sort out
| their garbage when they're supposed to be programming.
|
| They ought to learn how to program at school, it isn't
| gcc's job to teach them: its a compiler, not an interactive
| tutorial :-)
sure, but then we should remove all warnings :-/
| This comment refers to the original coder and NOT to
| Michael, who appears to have been stuck with having to fix it.
that comment is not very useful for Matt.
-- Gaby