egcs-971031: const_cast<char *&> (const char *&) failed

Teemu Torma tot@Trema.COM
Thu Nov 6 00:43:00 GMT 1997


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



More information about the Gcc-bugs mailing list