I got the following test code from http://support.microsoft.com/kb/131322:
const int * pi = new int(1000);
const char * pch = new char(65);
void main(void)
{
delete pi ;// Error C2710:cannot delete a pointer to a const object
delete pch ;// Error C2710:cannot delete a pointer to a const object
}
On that page Microsoft claims that deleting a pointer-to-const is not allowed, which seems logical to me. You don't want functions that you give a pointer-to-const to delete the instance behind your back.
Strange enough, question Deleting a pointer to const (T const*) indicates that it IS allowed, and it even makes sense.
And indeed, if I compile the code from the MSDN page with Visual Studio 2010, it compiles correctly (even no warnings when compiling with /W4).
Was the behavior regarding deletion of pointers-to-const changed in the past in the C++ standard? Or was this changed in Visual Studio?