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

            Bug ID: 127006
           Summary: ospanstream forces istream on ctor
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Darrell.Wright at gmail dot com
  Target Milestone: ---

The current implementation of ospanstreams ctor is using ios_base::in instead
of ios_base::out 

https://eel.is/c++draft/span.streams#ospanstream.cons-1



https://github.com/gcc-mirror/gcc/blob/f1933b5ba13bb2abd1329cfb1ba9501c90f4c516/libstdc%2B%2B-v3/include/std/spanstream#L346

   // [ospanstream.ctor], constructors
    explicit
    basic_ospanstream(std::span<_CharT> __s,
                      ios_base::openmode __which = ios_base::out)
    : __ostream_type(std::__addressof(_M_sb)),
      _M_sb(__s, __which | ios_base::in)
    { }

This makes code like 
std::ospanstream stream {std::span(buffer), std::ios_base::binary}; 

fail to be writable

Reply via email to