public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102028] New: std::ostream& used as std::stringstream&
@ 2021-08-23 18:20 lars.maier at tefax dot net
  2021-08-23 19:48 ` [Bug c++/102028] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: lars.maier at tefax dot net @ 2021-08-23 18:20 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-24 11:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23 18:20 [Bug c++/102028] New: std::ostream& used as std::stringstream& lars.maier at tefax dot net
2021-08-23 19:48 ` [Bug c++/102028] " pinskia at gcc dot gnu.org
2021-08-23 20:00 ` lars.maier at tefax dot net
2021-08-23 20:18 ` pinskia at gcc dot gnu.org
2021-08-24 11:02 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).