I found another bug, and a serious one. :-(((
Just try:
CObject * foo = new CObject[4]; // any amount will do
delete [] foo;
The delete[] will trash the heap. In debug build you'll get an assert and a
chance to abort the program beore it goes to an access violation.
Any class derived from CObject will do the same. Other classes seem not.
Probably the bug is related to the fact CObject has an operator new and
delete pair.
Going to assembly one can see the delete will call the scalar delete instead
of the vector delete, just if you mistakenly tried to use the simple delete
on the array.
- ------------------------------------------
Another related question: CObject has no default callable ctors:
CObject * foo = new CObject;
will not compile as the only ctor is protected.
Then the question: is it legal to create an array as I did above? That
compiles without even a warning and that protected ctor is simply called.
Paul
... Remove cat from keyboard to continue.
--- OS/2 Warp
---------------
* Origin: The FlintStones' Cave in BedRock (2:371/20)
|