| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // <ios> |
| 10 | |
| 11 | // class ios_base |
| 12 | |
| 13 | // void*& pword(int idx); |
| 14 | |
| 15 | // This test compiles but never completes when compiled against the MSVC STL |
| 16 | // UNSUPPORTED: stdlib=msvc |
| 17 | |
| 18 | #include <ios> |
| 19 | #include <string> |
| 20 | #include <cassert> |
| 21 | #include <cstdint> |
| 22 | |
| 23 | #include "test_macros.h" |
| 24 | |
| 25 | class test |
| 26 | : public std::ios |
| 27 | { |
| 28 | public: |
| 29 | test() |
| 30 | { |
| 31 | init(sb: 0); |
| 32 | } |
| 33 | }; |
| 34 | |
| 35 | int main(int, char**) |
| 36 | { |
| 37 | test t; |
| 38 | std::ios_base& b = t; |
| 39 | for (std::intptr_t i = 0; i < 10000; ++i) |
| 40 | { |
| 41 | assert(b.pword(i) == 0); |
| 42 | b.pword(ix: i) = (void*)i; |
| 43 | assert(b.pword(i) == (void*)i); |
| 44 | for (std::intptr_t j = 0; j <= i; ++j) |
| 45 | assert(b.pword(j) == (void*)j); |
| 46 | } |
| 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |