egcs allows deletion of const objects.

Bill Currie bcurrie@tssc.co.nz
Mon Oct 5 19:56:00 GMT 1998


Ross Smith wrote:
> 
> From: Louidor Erez <s3824888@techst02.technion.ac.il>
> >Here is another bug I've found:
> >
> >int main() {
> >  const char* string = new char();
> >  delete string;   // This shouldn't be allowed.
> >}
> >
> >The delete operator cannot be applied to a pointer to const object,
> >however egcs compiled it without a diagnostic.
> 
> EGCS is correct; your assumption is wrong. From the C++ standard
> (actually CD2, but I don't believe this has been changed), section
> 5.3.5 [expr.delete]:

I believe Louidor may have been thinking of deleting const pointers (eg
char * const foo).  A subtle but important difference (and easy to
confuse, especially after a late night or two).

Bill
-- 
Leave others their otherness



More information about the Gcc-bugs mailing list