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: g++ gives gratuitous "will use a temporary" warnings in CVS 19990611


On Jul 10, 1999, Daniel Jacobowitz <drow@false.org> wrote:

> The attached test program shows a warning regression in g++:

> test.cc:5: initializing non-const `const char *&' with `char *' will use a temporary
> test.cc:1: in passing argument 1 of `f(const char *&)'

It's not a regression, it really uses a temporary, even though it
shouldn't.  The code is ill-formed, see
http://reality.sgi.com/austern/std-c++/faq.html#C1

> void f(const char *&c);
> void g() { char *d; f(d); }

You should write:

void f(const char *const &c);

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{dcc.unicamp.br,guarana.{org,com}} aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them


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