On Thursday 26 October 2006 21:06, Murray Cumming wrote: > On Thu, 2006-10-26 at 20:36 +0200, stephan beal wrote: > > IMO, any change which fixes undefined behaviour should be made > > regardless of any perceived performance hit. > > If you can submit a test case I will consider it. I don't think there > is any bug, so you have to show that it exists. The point is that it's officially, according to the C++ Standard, *undefined* behaviour. Relying on undefined behaviour is a bug in waiting, and the "undefined" part inherently makes it difficult to "prove" to be problematic. > > Whether it's undefined only when i delete using a parent pointer or > > a child pointer is irrelevant. Opening the door to undefined > > behaviour leads to undefined behaviour. The door shouldn't even be > > open. > > C++ does not protect you from errors. You must know what you are > doing. But you needn't know the function signature of every function which you never call - the compiler calls the dtor for you, and that's where the trap is. > Likewise, you can provide an incorrect reference to a std::list<>, > and it will cause a crash (or "undefined behaviour"). That type of bug is generally easy to find post facto, and a stack trace will lead you right to it. Finding an un-called dtor is a lot trickier, and finding the reason for it is probably just as tricky because the first reaction to actually finding such a bug would likely be "what the foo is going on here?" rather than "oh, that means one of my bases is missing a virtual dtor!" > > A dtor > > is a function call, too, so i will argue that any public > > subclassing is automatic polymorphic behaviour. > > That's quite clearly wrong. C++ is not as simple as you'd like it to > be. As i said earlier, we can nit-pick the semantics of polymorphism all day and not come to a satisfying agreement. Obviously, i'm not going to change any minds here, and i'll just say that i would never personally ask client code to subclass a type of mine for which provided no virtual dtor. i'll shut up now. -- ----- stephan s11n net http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts
Attachment:
pgpeUuH68GkUy.pgp
Description: PGP signature