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]
Other format: [Raw text]

[Bug c++/48296] New: constexpr member function cannot use the class type it belongs as parameter type or return type


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48296

           Summary: constexpr member function cannot use the class type it
                    belongs as parameter type or return type
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: boostcpp@gmail.com


constexpr member function cannot use the class type it belongs as parameter
type or return type.
gcc issues errors for the following code.

struct X
{
    constexpr X() { }

    // error : invalid parameter type and return type.
    // same for static and non-static member function
    constexpr X f( X x ) { return x ; }
} ;

I think this is a well-formed code.

Base class name can be used.

Also gcc issues errors for the following code which I think it's caused by the
same problem.

struct X
{
    constexpr X() { }

    // declaration
    constexpr X f( X x ) ;
} ;
// definition
// error : redeclaration differs
constexpr X X::f( X x ) { return x ; }

There is no difference in the redeclaration.
So this error is wrong.


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