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

            Bug ID: 102028
           Summary: std::ostream& used as std::stringstream&
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lars.maier at tefax dot net
  Target Milestone: ---

The following code compiles, although it shouldn't:
```
#include <sstream>
#include <iostream>

void foo(std::stringstream const&);

struct A {
    friend auto operator<<(std::ostream& os, A const&) -> std::ostream&;
};


int main() {
    foo(std::stringstream{} << A{});
    return 0;
}
```
Reason: the result of operator<< with std::stringstream and A const& is just an
std::ostream& and you should not be able to call foo on such an reference.

Reply via email to