This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21353] New: rvalues should not be allowed to be default values for non const references in class functions.
- From: "s_siddharth_reddy at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 May 2005 08:50:44 -0000
- Subject: [Bug c++/21353] New: rvalues should not be allowed to be default values for non const references in class functions.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
works as expected on : gcc 2.95, freebsd/linux
does not work as expected on: gcc 3.4.2, freebsd/linux
//non-const references to temp values should be disallowed
--------------
//the code
enum X{ a, b, c };
class C
{
public:
void func( X & ref = a ) //illegal - should not compile.
{ }
};
int main( )
{ }
//compile with gcc 2.95
$g++ test2.cpp
test2.cpp:7: invalid type `X' for default argument to `X &'
//compile with gcc 3.4.2
$g++3 test2.cpp
$
----------------
this problem does not exist for functions in global scope.
--
Summary: rvalues should not be allowed to be default values for
non const references in class functions.
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: s_siddharth_reddy at yahoo dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21353