This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: g++ gives gratuitous "will use a temporary" warnings in CVS 19990611
- To: Daniel Jacobowitz <drow at false dot org>
- Subject: Re: g++ gives gratuitous "will use a temporary" warnings in CVS 19990611
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 13 Jul 1999 02:28:57 -0300
- Cc: egcs-bugs at egcs dot cygnus dot com
- References: <19990710042745.A29341@drow.res.cmu.edu>
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