This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
egcs-971031: const_cast<char *&> (const char *&) failed
- To: egcs-bugs at cygnus dot com
- Subject: egcs-971031: const_cast<char *&> (const char *&) failed
- From: Teemu Torma <tot at Trema dot COM>
- Date: Thu, 06 Nov 1997 09:39:04 +0100
- Organization: Trema Laboratories SARL
gcc -v
Reading specs from /usr/gnu/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.15/specs
gcc version egcs-2.90.15 971031 (gcc2-970802 experimental)
In the following code, the first const_cast is ok, but the second
fails with:
const_cast.cc: In function `char *& t1(const char *&)':
const_cast.cc:8: warning: converting to `char *' from `const char *' discards const
const_cast.cc:8: warning: initializing non-const `char *&' with `const char *' will use a temporary
const_cast.cc:8: warning: returning reference to temporary
---------------------------------------------------------------------------
char *t1 (const char *s)
{
return const_cast<char *>(s);
}
char *&t1 (const char *&s)
{
return const_cast<char *&>(s);
}
---------------------------------------------------------------------------
Teemu