This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14458] New: 3.4 Regression : const_cast suddenly (treated as) temporary?
- From: "carlo at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Mar 2004 15:27:07 -0000
- Subject: [Bug c++/14458] New: 3.4 Regression : const_cast suddenly (treated as) temporary?
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following compiles with 3.3.x. Is does not compile with
3.4 or 3.5 cvs.
~/c++/g++.bugs/bug17>cat test.cc
// Note, though it may seem weird here, in my application this MUST be a char*&.
void f(char const*&) { }
void g(void)
{
char* p;
f(const_cast<char const*>(p));
}
~/c++/g++.bugs/bug17>g++-3.3.3 -c test.cc
~/c++/g++.bugs/bug17>
~/c++/g++.bugs/bug17>g++-cvs-3.4 -c test.cc
test.cc: In function `void g()':
test.cc:7: error: invalid initialization of non-const reference of type 'const
char*&' from a temporary of type 'const char*'
test.cc:2: error: in passing argument 1 of `void f(const char*&)'
I didn't check if const_cast<> is now actually calling a
copy constructor, but considering some types have private
copyconstructors or really don't want it to be called, this
makes const_cast<> suddenly a step back from the plain old
C-cast :/
--
Summary: 3.4 Regression : const_cast suddenly (treated as)
temporary?
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: carlo at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14458