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++/34023] New: Wrong using of user-defined conversion operator for converting rvalue to reference on constant.


// gcc version 3.4.5 (mingw-special)
class a
{
public:

        template<class T>
        operator T &() const
        {
                static int f;
                return f; // line # 10
        }

        /* 
        // unsafe workaround:
        operator a const &() const
        {
                return *this;
        }
        */
};

int main()
{
        // : In member function `a::operator T&() const [with T = const a]':
        // :27:   instantiated from here
        // :10: error: invalid initialization of reference of type 'const a&'
from expression of type 'int'
        a const &aa = a(); // line # 27
        /*
        // workaround:
        a const temp;
        a const &aa = temp;
        */
}


-- 
           Summary: Wrong using of user-defined conversion operator for
                    converting rvalue to reference on constant.
           Product: gcc
           Version: 3.4.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sergey dot gcc at comrades dot id dot au


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


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