Skip to content

Commit df63ed5

Browse files
rsteinkeXMongoDB Bot
authored andcommitted
SERVER-103783 Fix NAN string on windows. (#35628)
GitOrigin-RevId: 821440affc6eeee7dc71cc656f9b94499e0d6dd0
1 parent f77bff7 commit df63ed5

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/mongo/bson/util/builder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,8 @@ class StringBuilderImpl {
771771
const int prev = _buf.len();
772772
const int maxSize = 32;
773773
char* start = _buf.grow(maxSize);
774-
int z = snprintf(start, maxSize, "%.16g", x);
774+
int z = std::isnan(x) ? "nan\0"_sd.copy(start, maxSize) - 1
775+
: snprintf(start, maxSize, "%.16g", x);
775776
MONGO_verify(z >= 0);
776777
MONGO_verify(z < maxSize);
777778
_buf.setlen(prev + z);

src/mongo/idl/idl_test.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,7 @@ TEST(IDLOneTypeTests, TestBase64StringNegative) {
444444
}
445445

446446

447-
// BSONElement::exactNumberLong() provides different errors on windows
448-
#ifdef _WIN32
449-
constexpr auto kNANRepr = "-nan(ind)"_sd;
450-
#else
451447
constexpr auto kNANRepr = "nan"_sd;
452-
#endif
453448

454449
TEST(IDLStructTests, DurationParse) {
455450
IDLParserContext ctxt("duration");

0 commit comments

Comments
 (0)