I have been working on some legacy C++ code that uses variable length structures (TAPI), where the structure size will depend on variable length strings. The structures are allo
The behaviour of the code is undefined. You may be lucky (or not) and it may work with your compiler, but really that's not correct code. There's two problems with it:
delete
should be an array delete []
.delete
should be called on a pointer to the same type as the type allocated.So to be entirely correct, you want to be doing something like this:
delete [] (BYTE*)(pStruct);