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

Reply via email to