Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!brutus.cs.uiuc.edu!jarthur!uci-ics!gateway From: schmidt@crimee.ics.uci.edu (Doug Schmidt) Newsgroups: gnu.g++.bug Subject: Re: array size expression for delete Message-ID: <25E9CB6A.19890@paris.ics.uci.edu> Date: 27 Feb 90 00:35:54 GMT References: <9002262348.AA12899@maui.cs.ucla.edu> Reply-To: schmidt@crimee.ics.uci.edu (Doug Schmidt) Distribution: gnu Organization: University of California, Irvine - Dept of ICS Lines: 31 In-reply-to: rjc@CS.UCLA.EDU (Robert Collins) In article <9002262348.AA12899@maui.cs.ucla.edu>, rjc@CS (Robert Collins) writes: >Michael, > >When I use the syntax > delete [size] array; >and compile with '-O -Wall', I am told > file.cc: warning: array size expression for delete ignored > > >This sounds ominous. Is the [size] really ignored? Is only the first >element of my array being destroyed? Is the warning bogus? Is my code >bogus? Do you need some sample (bogus?) code? Check the type of `array'. If it is a pointer-to-built-in type, e.g., a char *, or int *, or double * then there is clearly no destructor, so the `size' doesn't need to be used to free the memory (if the compiler generates code to simply call free (array) this does the trick). On the other hand, if array points to objects of a user-defined class type with a destructor then the size *does* matter (since that many destructor calls must be made, one for each element in the area pointed to by array). Unless you've got an instance of the latter case I think everything is ok! Doug -- On a clear day, under blue skies, there is no need to seek. And asking about Buddha +------------------------+ Is like proclaiming innocence, | schmidt@ics.uci.edu | With loot in your pocket. | office: (714) 856-4043 |