This is the mail archive of the 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: Request for a C++ warning for undefined behaviour

skaller <> writes:

| On Wed, 2003-08-13 at 21:01, Michael Matz wrote:
| > Hi,
| > 
| > On 13 Aug 2003, skaller wrote:
| > 
| > > If you write that kind of code you deserve everything you get.
| > 
| > Well, that's the case for all errors one made.  
| 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.

| The code exhibited appears quite perverted to me ..
| well, I'm assuming you weren't trying to call a global
| function f, and picked up the member f by accident
| (that would be an more honest mistake).

As he said in his initial message, he had to figure out that bug in a
code he was working on, as a maintainer or sort of.


| > > Since you shouldn't be writing code anything remotely like this in the
| > > first place, it hardly seems like it would be worthwhile to provide a
| > > special case check here.
| > 
| > That's not a logical conclusion. 
| The conclusion follows from the assumption that
| detecting possible mistakes in code that is using
| a faulty design is worthwhile. Better to fix the design.
| >  Besides, usefullness lies in the eye of
| > the beholder.  Indeed from your above remarks I would conclude that this
| > warning would also be useful to you, because you already made an error in
| > your assumptions, namely that you can call non-virtual members.
| 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.  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, 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.  He
is not asking for a perfect knife.

-- Gaby

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