[Bug c++/84918] Better handling of "std::cout >> 42;"

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Mar 17 12:37:00 GMT 2018


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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This seems pretty low priority though, there's a lot of output, but all of it
tells you the problem:

42.cc:4:18: note:   ‘std::ostream {aka std::basic_ostream<char>}’ is not
derived from ‘std::basic_istream<_CharT, _Traits>’
     std::cout >> 42;
                  ^~

I'd much rather see a solution to the more general problem of drowning the user
in information when the overload set is very large. That happens with many
operators, but especially << and >>. A special case to reduce that just for the
trivial typo of using >> when you mean << doesn't help the common case.

See PR 58713 comment 6 and 7


More information about the Gcc-bugs mailing list