Topic: delete 'void *' undefined


Author: "Charles E. Arnold" <cearnold@dallas.net>
Date: Wed, 13 Feb 2002 22:03:30 GMT
Raw View
Hi all,

   I am getting a warning message:

warning: deleting 'void *' is undefined

   Is this 'standard' behaviour? If so,
could someone give me reference(s) I could
show my teacher?

Thanks for any insight.

-Arnold, C. E.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "Carl Daniel" <cpdaniel@pacbell.net>
Date: Thu, 14 Feb 2002 00:03:06 GMT
Raw View
"Charles E. Arnold" <cearnold@dallas.net> wrote in message
news:u6lhr7cjeah62b@corp.supernews.com...
> Hi all,
>
>    I am getting a warning message:
>
> warning: deleting 'void *' is undefined
>
>    Is this 'standard' behaviour? If so,
> could someone give me reference(s) I could
> show my teacher?

The Standard:

5.3.5/3 "...if the static type of the operand is different from its dynamic
type, the static type shall be a base class of the operand's dynamic type
and the static type shall have a virtual destructor or the behavior is
undefined".

5.3.5/5 "If the object being deleted has incomplete class type at the point
of deletion and the complete class has a non-trivial destructor or a
deallocation function, the behavior is undefined."

3.9.1/9 "... The void type is an incomplete type that cannot be completed".

so, if you write:

void* p = ....;
// ...
delete p;

Since there can be no objects of type 'void', and 'void' cannot be a base
class of any type, the expression has undefined behavior according to
5.2.5/3.  If that weren't bad enough, void is an imcomplete type, so the
behavior is likely to be undefined according to 5.3.5/5 as well (although
that depends on what p points to).

-cd




---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]