<locale>: wbuffer_convert does not implement seek
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
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/e36ee6c2b9bc6f5b1f70776c18cf5d3a93a69798/tests/libcxx/expected_results.txt#L404-L405
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided main.cpp case for std::wbuffer_convert and inspect [depr.conversions.buffer], which the report says is underspecified. Review the skipped entry in tests/libcxx/expected_results.txt and determine the intended seek behavior; done means the relevant test expectations and the supplied seek assertions agree.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100