> Using vc6 sp5 the following code fails during delete, due to the base
> class having a virtual destructor.
It is a known defect of the implementation. Your sample code meets just
the requirements that should be met to reproduce the behavior: an
attempt to delete a zero-sized array of polymorphic objects. It is
perfectly legal in C++, but MSVC++ 6 will choke on it at run-time.
A simple investigation will reveal the reason for the crash: the code
attempts to access virtual destructor through the VMT of the first
element in the array, which results in a crash, since there is no first
element in your case. Looks like Microsoft in their MSVC++ 6
implementation decided to support polymorphic deletion of arrays (which
is not a part of C++ standard). It would make a legitimate MS-specific
extension and someone would probably find it useful, but they managed to
screw up along the way and came up with an implementation that produces
a crash in a perfectly standard compliant code.
Brainbench C and C++ Programming MVP