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]

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


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


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