Bug 104032 - Cannot move-assign a spanstream
Summary: Cannot move-assign a spanstream
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: 12.0
Assignee: Jonathan Wakely
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2022-01-14 16:20 UTC by ensadc
Modified: 2022-01-23 22:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2022-01-15 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ensadc 2022-01-14 16:20:15 UTC
https://godbolt.org/z/GxdYrYYrj

====
#include <spanstream>

int main() {
    std::ispanstream a(""), b("");
    a = std::move(b);
}

====
In file included from <source>:1:
/opt/compiler-explorer/gcc-trunk-20220114/include/c++/12.0.0/spanstream: In instantiation of 'std::basic_spanbuf<_CharT, _Traits>& std::basic_spanbuf<_CharT, _Traits>::operator=(std::basic_spanbuf<_CharT, _Traits>&&) [with _CharT = char; _Traits = std::char_traits<char>]':
/opt/compiler-explorer/gcc-trunk-20220114/include/c++/12.0.0/spanstream:258:24:   required from here
/opt/compiler-explorer/gcc-trunk-20220114/include/c++/12.0.0/spanstream:89:7: error: base operand of '->' has non-pointer type 'std::basic_spanbuf<char>'
   89 |       basic_spanbuf(std::move(__rhs))->swap(*this);
      |       ^~~~~~~~~~~~~
Comment 1 GCC Commits 2022-01-23 22:49:55 UTC
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:51631875a2fa0af62ebda7484ac48368e1805dff

commit r12-6829-g51631875a2fa0af62ebda7484ac48368e1805dff
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Sun Jan 23 21:55:57 2022 +0000

    libstdc++: Fix std::spanstream move assignment [PR104032]
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/104032
            * include/std/spanstream (basic_spanbuf(basic_spanbuf&&)): Use
            mem-initializer for _M_buf.
            (basic_spanbuf::Operator=(basic_spanbuf&&)): Fix ill-formed
            member access.
            * testsuite/27_io/spanstream/2.cc: New test.
Comment 2 Jonathan Wakely 2022-01-23 22:54:40 UTC
Fixed, thanks for the report.