Skip to content

Commit ca69f51

Browse files
authored
[libcxx] [test] Detect the UCRT printf("%a") formatting bug (#99846)
This fixes testing with MinGW, if built without __USE_MINGW_ANSI_STDIO=1. On x86 MinGW, such a configuration fails printf tests with long doubles due to mismatches between 80 and 64 bit long doubles - but on ARM, there's no such issue, so building without __USE_MINGW_ANSI_STDIO=1 is perfectly valid there. Add another similar XFAIL to a libcxxabi test; this test isn't executed in MSVC environments, so no XFAIL has been needed so far.
1 parent 481eb4f commit ca69f51

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.hex.pass.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212

1313
// iter_type put(iter_type s, ios_base& iob, char_type fill, double v) const;
1414

15-
// With the Microsoft UCRT, printf("%a", 0.0) produces "0x0.0000000000000p+0"
16-
// while other C runtimes produce just "0x0p+0".
17-
// https://developercommunity.visualstudio.com/t/Printf-formatting-of-float-as-hex-prints/1660844
18-
// XFAIL: msvc
15+
// XFAIL: win32-broken-printf-a-precision
1916

2017
// XFAIL: LIBCXX-AIX-FIXME
2118

libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.hex.pass.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212

1313
// iter_type put(iter_type s, ios_base& iob, char_type fill, long double v) const;
1414

15-
// With the Microsoft UCRT, printf("%a", 0.0) produces "0x0.0000000000000p+0"
16-
// while other C runtimes produce just "0x0p+0".
17-
// https://developercommunity.visualstudio.com/t/Printf-formatting-of-float-as-hex-prints/1660844
18-
// XFAIL: msvc
15+
// XFAIL: win32-broken-printf-a-precision
1916

2017
// XFAIL: LIBCXX-AIX-FIXME
2118

libcxx/utils/libcxx/test/features.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,26 @@ def _mingwSupportsModules(cfg):
263263
""",
264264
),
265265
),
266+
# Check for a Windows UCRT bug (not fixed upstream yet).
267+
# With UCRT, printf("%a", 0.0) produces "0x0.0000000000000p+0",
268+
# while other C runtimes produce just "0x0p+0".
269+
# https://developercommunity.visualstudio.com/t/Printf-formatting-of-float-as-hex-prints/1660844
270+
Feature(
271+
name="win32-broken-printf-a-precision",
272+
when=lambda cfg: "_WIN32" in compilerMacros(cfg)
273+
and not programSucceeds(
274+
cfg,
275+
"""
276+
#include <stdio.h>
277+
#include <string.h>
278+
int main(int, char**) {
279+
char buf[100];
280+
snprintf(buf, sizeof(buf), "%a", 0.0);
281+
return strcmp(buf, "0x0p+0");
282+
}
283+
""",
284+
),
285+
),
266286
# Check for Glibc < 2.27, where the ru_RU.UTF-8 locale had
267287
# mon_decimal_point == ".", which our tests don't handle.
268288
Feature(

libcxxabi/test/test_demangle.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// 80-bit format, and this demangling test is failing on it.
1818
// XFAIL: LIBCXX-ANDROID-FIXME && target={{i686|x86_64}}-{{.+}}-android{{.*}}
1919

20+
// XFAIL: win32-broken-printf-a-precision
21+
2022
#include "support/timer.h"
2123
#include <algorithm>
2224
#include <cassert>

0 commit comments

Comments
 (0)