[Bug c++/32085] "warning: deleting void* is undefined" sometimes bogus
bangerth at dealii dot org
gcc-bugzilla@gcc.gnu.org
Wed May 30 05:14:00 GMT 2007
------- Comment #8 from bangerth at dealii dot org 2007-05-30 05:13 -------
The point Gabriel and the others are trying to make is that when
calling operator delete on a pointer, first the object is destroyed
by calling the destructor (or doing nothing in case this is a plain-old-data
type), then the memory is deallocated (or whatever
else operator delete wants to do with it). Now, since you pass a
void *, the compiler can't know what to do about step 1: it is unknown whether
a destructor should be called or not. It simply doesn't make sense to
call operator delete on a void*. If you're sure that the object pointed to
doesn't need a destructor call, you could cast the pointer to char*, but
if you don't the standard says that the compiler could do whatever it pleases.
I, too, fail to see why anyone would want to switch this warning off, rather
than modifying the code to tell the compiler what the heck to do in a situation
where it simply can't know what to do...
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32085
More information about the Gcc-bugs
mailing list