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++/69924] gcc5.2 compile Error: std::basic_istream: no match for 'operator>>', while gcc 4.8 works


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69924

derrick at ca dot ibm.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |FIXED

--- Comment #3 from derrick at ca dot ibm.com ---
"I assume you're compiling as C++11?"
- Oh, yes, with -std=c++11 flag:
  $g++ -std=c++11 ./_222d00_s.cpp -o test

"This is not valid C++11 code, there is no implicit conversion from streams to
void* or bool in C++11."

- But after I add static_cast<bool>, it still has the error. It looks like  
"loc" has some problem. If you think the code is invalid under C++11, could you
point out how I could modify the code to make it pass. Thanks.


#include <iostream>
#include <locale>

inline int operator<<(void*,       const std::locale&) { return 1; }
inline int operator>>(void*,       const std::locale&) { return 1; }
inline int operator<<(bool,        const std::locale&) { return 2; }
inline int operator>>(bool,        const std::locale&) { return 2; }

int main(int argc, char *argv[])
{

          std::locale loc;
          if(static_cast<bool>(std::cin  >> loc)!=1)
             return 1;
          if(static_cast<bool>(std::cout << loc)!=1);
             return 1;

          return 0;
}

error: no match for 'operator>>' (operand types are 'std::istream {aka
std::basic_istream<char>}' and 'std::locale')
    if(static_cast<bool>(std::cin  >> loc)!=1)
 error: cannot bind 'std::istream {aka std::basic_istream<char>}' lvalue to
'std::basic_istream<char>&&'
    if(static_cast<bool>(std::cin  >> loc)!=1)

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