-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix writing NaN to the output stream with a set locale (#3868)
Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
- Loading branch information
1 parent
0574f20
commit 28ea30a
Showing
4 changed files
with
47 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
RUNALL_INCLUDE ..\usual_matrix.lst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#include <cassert> | ||
#include <limits> | ||
#include <locale> | ||
#include <sstream> | ||
|
||
using namespace std; | ||
|
||
template <typename T> | ||
void test_gh_3867() { | ||
// GH-3867 Writing NaN to the output stream with a set locale results in a weird output | ||
ostringstream s; | ||
s.imbue(locale("en-US")); | ||
s << -numeric_limits<T>::quiet_NaN(); | ||
assert(s.str() == "-nan(ind)"); | ||
} | ||
|
||
int main() { | ||
test_gh_3867<float>(); | ||
test_gh_3867<double>(); | ||
test_gh_3867<long double>(); | ||
} |