diff options
| author | Marshall Clow <mclow.lists@gmail.com> | 2019-09-13 15:28:06 +0000 |
|---|---|---|
| committer | Marshall Clow <mclow.lists@gmail.com> | 2019-09-13 15:28:06 +0000 |
| commit | 7b81a13bfcd1d92f478109f1c87971dafba639d2 (patch) | |
| tree | 1dc90fe12b7adbacc6ae297317d628366c245ee1 /libcxx/test | |
| parent | 24c1ab26331ae218f27659a1a26cc72d8a264482 (diff) | |
| download | bcm5719-llvm-7b81a13bfcd1d92f478109f1c87971dafba639d2.tar.gz bcm5719-llvm-7b81a13bfcd1d92f478109f1c87971dafba639d2.zip | |
Only initialize the streams cout/wcout/cerr/wcerr etc once, rather than any time Init::Init is called. Fixes PR#43300
llvm-svn: 371864
Diffstat (limited to 'libcxx/test')
| -rw-r--r-- | libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/ios_Init.multiple.pass.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/ios_Init.multiple.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/ios_Init.multiple.pass.cpp new file mode 100644 index 00000000000..37b4de9def5 --- /dev/null +++ b/libcxx/test/std/input.output/iostreams.base/ios.base/ios.types/ios_Init/ios_Init.multiple.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include <iostream> +#include <cassert> + +#include "test_macros.h" + +// Test to make sure that the streams only get initialized once +// Taken from https://bugs.llvm.org/show_bug.cgi?id=43300 + +int main(int, char**) +{ + + std::cout << "Hello!"; + std::ios_base::fmtflags stock_flags = std::cout.flags(); + + std::cout << std::boolalpha << true; + std::ios_base::fmtflags ba_flags = std::cout.flags(); + assert(stock_flags != ba_flags); + + std::ios_base::Init init_streams; + std::ios_base::fmtflags after_init = std::cout.flags(); + assert(after_init == ba_flags); + + return 0; +} |

