This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: RV: bug in new expr?
- To: Robert Lipe <robertl at sco dot com>
- Subject: Re: RV: bug in new expr?
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 03 Jul 1999 14:55:40 -0300
- Cc: egcs-bugs at egcs dot cygnus dot com, mitosys at colomsat dot net dot co
- References: <19990702143303.H741@rjlhome.sco.com>
On Jul 2, 1999, Robert Lipe <robertl@sco.com> wrote:
> Arturo Josi Montes Sinning wrote:
>> long** l = new (long * [argc]);
This allocates an array of argc pointers to long and returns a pointer
to the first element, so `l' cannot be null. If it ever was, it was a
bug.
>> long** l = new (long*) [argc];
This allocates a *single* pointer to long and returns a pointer to
it, which is dereferenced as if it pointed to an array, using index
[argc], which is obviously incorrect, but the compiler can't tell in
general, since argc might be zero. But it has probably warned about
converting the long* that results from that expression to long**.
--
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
{oliva,Alexandre.Oliva}@dcc.unicamp.br aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists