This is the mail archive of the gcc-bugs@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: RV: bug in new expr?


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


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