This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: delete[] works on static arrays


>>>>> Alexandre Oliva <oliva@dcc.unicamp.br> writes:

> --Multipart_Sun_Jun__7_17:24:32_1998-1
> Content-Type: text/plain; charset=US-ASCII

> Guillaume Laurent <glaurent@worldnet.fr> writes:

>> The following compiles cleanly with egcs 1.0.3, while it shouldn't :

>> int main(void) { char a[120]; delete[] a; return 0; }

I'm not sure about that.  The draft says

            The operand shall have a pointer type, or a class type having
  a single conversion function (_class.conv.fct_)  to  a  pointer  type.

but it also says, about array references, that

  One of the expressions shall have the type "pointer to T"

so I think that the pointer can be the result of the default
array-to-pointer conversion.  If so, this code is well-formed, and the
current error message for 'delete' is wrong.  Existing practice is mixed.
EDG, Sun and Diab accept it; HP and IBM reject it.

I would suggest moving the check to before the switch, making it a
warning, and adding a call to build_expr_type_conversion.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]