public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14458] New: 3.4 Regression : const_cast suddenly (treated as) temporary?
@ 2004-03-06 15:27 carlo at gcc dot gnu dot org
2004-03-06 16:27 ` [Bug c++/14458] " pcarlini at suse dot de
2004-03-06 18:18 ` pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: carlo at gcc dot gnu dot org @ 2004-03-06 15:27 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/14458] 3.4 Regression : const_cast suddenly (treated as) temporary?
2004-03-06 15:27 [Bug c++/14458] New: 3.4 Regression : const_cast suddenly (treated as) temporary? carlo at gcc dot gnu dot org
@ 2004-03-06 16:27 ` pcarlini at suse dot de
2004-03-06 18:18 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pcarlini at suse dot de @ 2004-03-06 16:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pcarlini at suse dot de 2004-03-06 16:27 -------
According to 5.2.11, p1: "The result of the expression const_cast<T>(v) is of
type T. If T is a reference type, the result is an lvalue; otherwise, the result
is an rvalue and, ...", therefore the current behavior seems definitely correct.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14458
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/14458] 3.4 Regression : const_cast suddenly (treated as) temporary?
2004-03-06 15:27 [Bug c++/14458] New: 3.4 Regression : const_cast suddenly (treated as) temporary? carlo at gcc dot gnu dot org
2004-03-06 16:27 ` [Bug c++/14458] " pcarlini at suse dot de
@ 2004-03-06 18:18 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-06 18:18 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-06 18:18 -------
See Paolo's explanation.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14458
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-03-06 18:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-06 15:27 [Bug c++/14458] New: 3.4 Regression : const_cast suddenly (treated as) temporary? carlo at gcc dot gnu dot org
2004-03-06 16:27 ` [Bug c++/14458] " pcarlini at suse dot de
2004-03-06 18:18 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).