STL icon indicating copy to clipboard operation
STL copied to clipboard

<locale>: wbuffer_convert does not implement seek

Open fsb4000 opened this issue 5 years ago • 0 comments

Describe the bug STL Bug? Our wbuffer_convert does not implement seek. [depr.conversions.buffer] is completely underspecified.

Command-line test case

C:\Temp>type main.cpp
#include <locale>
#include <codecvt>
#include <fstream>
#include <cassert>

class test_codecvt
    : public std::codecvt<wchar_t, char, std::mbstate_t>
{
    typedef std::codecvt<wchar_t, char, std::mbstate_t> base;
public:
    explicit test_codecvt(std::size_t refs = 0) : base(refs) {}
    ~test_codecvt() {}
};

int main()
{
    {
        wchar_t buf[10];
        typedef std::wbuffer_convert<test_codecvt> test_buf;
        typedef test_buf::pos_type pos_type;
        std::fstream bs("seekoff.dat", std::ios::trunc | std::ios::in
                                                       | std::ios::out);
        test_buf f(bs.rdbuf());
        f.pubsetbuf(buf, sizeof(buf)/sizeof(buf[0]));
        f.sputn(L"abcdefghijklmnopqrstuvwxyz", 26);
        assert(buf[0] == L'v');
        pos_type p = f.pubseekoff(-15, std::ios_base::cur);
        assert(p == 11);
        assert(f.sgetc() == L'l');
        f.pubseekoff(0, std::ios_base::beg);
        assert(f.sgetc() == L'a');
        f.pubseekoff(-1, std::ios_base::end);
        assert(f.sgetc() == L'z');
        assert(f.pubseekpos(p) == p);
        assert(f.sgetc() == L'l');
    }
    std::remove("seekoff.dat");
}

C:\Temp>cl /EHsc /W4 /WX main.cpp
Оптимизирующий компилятор Microsoft (R) C/C++ версии 19.28.29213 для x64
(C) Корпорация Майкрософт (Microsoft Corporation).  Все права защищены.

main.cpp
Microsoft (R) Incremental Linker Version 14.28.29213.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:main.exe
main.obj

C:\Temp>main.exe
Assertion failed: buf[0] == L'v', file main.cpp, line 26

Expected behavior Test should pass? gcc fails too... https://gcc.godbolt.org/z/zoTTxb

STL version Microsoft Visual Studio Community 2019 Preview Version 16.8.0 Preview 2.0

Additional context Skipped libcxx test https://github.com/microsoft/STL/blob/06827feb4cdc4d2328dfbfab9fd5302de6058dd9/tests/libcxx/expected_results.txt#L631-L632

fsb4000 avatar Sep 04 '20 16:09 fsb4000