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++/58713] New: error: cannot bind âstd::ostream {aka std::basic_ostream<char>}â lvalue to âstd::basic_ostream<char>&&â


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

            Bug ID: 58713
           Summary: error: cannot bind âstd::ostream {aka
                    std::basic_ostream<char>}â lvalue to
                    âstd::basic_ostream<char>&&â
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ali.baharev at gmail dot com

#include <iostream>

struct A { };

int main() {
    A a;
    std::cout << a;
}
-----

g++ 4.8.1, 64 bit with -std=c++11 gives the correct error message:

main.cpp:7:15: error: no match for âoperator<<â (operand types are
âstd::ostream {aka std::basic_ostream<char>}â and âAâ)
     std::cout << a;
               ^

However, 4.8.1, 32 bit or 4.7.2, 64 bit gives:

prog.cpp:7:18: error: cannot bind âstd::ostream {aka std::basic_ostream<char>}â
lvalue to âstd::basic_ostream<char>&&â
     std::cout << a;
                  ^
In file included from /usr/include/c++/4.8/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/4.8/ostream:602:5: error:   initializing argument 1 of
âstd::basic_ostream<_CharT, _Traits>&
std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT
= char; _Traits = std::char_traits<char>; _Tp = A]â
     operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x)
     ^

Could this rather confusing error message be improved?

Why do the 32 and 64 bit versions behave differently?

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