From ed6c55829f8b34daa2ec5c24e1d23cac2477ac57 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Fri, 13 Aug 2021 15:13:36 +0700 Subject: [PATCH 1/2] fix seekpos and seekoff --- stl/inc/streambuf | 4 ++-- tests/std/test.lst | 1 + .../env.lst | 4 ++++ .../test.compile.pass.cpp | 18 ++++++++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/std/tests/GH_002120_streambuf_seekpos_and_seekoff/env.lst create mode 100644 tests/std/tests/GH_002120_streambuf_seekpos_and_seekoff/test.compile.pass.cpp diff --git a/stl/inc/streambuf b/stl/inc/streambuf index 081b1ff9820..253bef015bd 100644 --- a/stl/inc/streambuf +++ b/stl/inc/streambuf @@ -357,12 +357,12 @@ protected: virtual pos_type __CLR_OR_THIS_CALL seekoff( off_type, ios_base::seekdir, ios_base::openmode = ios_base::in | ios_base::out) { // change position by offset, according to way and mode - return streampos(-1); + return pos_type(-1); } virtual pos_type __CLR_OR_THIS_CALL seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out) { // change to specified position, according to mode - return streampos(-1); + return pos_type(-1); } virtual basic_streambuf* __CLR_OR_THIS_CALL setbuf(_Elem*, streamsize) { diff --git a/tests/std/test.lst b/tests/std/test.lst index a4dbad8364e..49091719003 100644 --- a/tests/std/test.lst +++ b/tests/std/test.lst @@ -179,6 +179,7 @@ tests\GH_001850_clog_tied_to_cout tests\GH_001914_cached_position tests\GH_002039_byte_is_not_trivially_swappable tests\GH_002058_debug_iterator_race +tests\GH_002120_streambuf_seekpos_and_seekoff tests\LWG2597_complex_branch_cut tests\LWG3018_shared_ptr_function tests\P0019R8_atomic_ref diff --git a/tests/std/tests/GH_002120_streambuf_seekpos_and_seekoff/env.lst b/tests/std/tests/GH_002120_streambuf_seekpos_and_seekoff/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/GH_002120_streambuf_seekpos_and_seekoff/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/GH_002120_streambuf_seekpos_and_seekoff/test.compile.pass.cpp b/tests/std/tests/GH_002120_streambuf_seekpos_and_seekoff/test.compile.pass.cpp new file mode 100644 index 00000000000..085c405fffa --- /dev/null +++ b/tests/std/tests/GH_002120_streambuf_seekpos_and_seekoff/test.compile.pass.cpp @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +using namespace std; + +struct State {}; + +struct CharTraits : char_traits { + using state_type = State; + using pos_type = fpos; +}; + +struct Streambuf : basic_streambuf {}; + +int main() {} // COMPILE-ONLY From b2b2c67a280c5083885a644d656c461ffe73bdae Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sat, 14 Aug 2021 03:50:44 +0700 Subject: [PATCH 2/2] do as cppreference says: https://en.cppreference.com/w/cpp/io/basic_streambuf/pubseekpos --- stl/inc/streambuf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/streambuf b/stl/inc/streambuf index 253bef015bd..2cbe9506e80 100644 --- a/stl/inc/streambuf +++ b/stl/inc/streambuf @@ -357,12 +357,12 @@ protected: virtual pos_type __CLR_OR_THIS_CALL seekoff( off_type, ios_base::seekdir, ios_base::openmode = ios_base::in | ios_base::out) { // change position by offset, according to way and mode - return pos_type(-1); + return pos_type(off_type(-1)); } virtual pos_type __CLR_OR_THIS_CALL seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out) { // change to specified position, according to mode - return pos_type(-1); + return pos_type(off_type(-1)); } virtual basic_streambuf* __CLR_OR_THIS_CALL setbuf(_Elem*, streamsize) {