Skip to content

Commit

Permalink
[libcxx] [test] Detect the UCRT printf("%a") formatting bug (llvm#99846)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mstorsjo committed Jul 26, 2024
1 parent 481eb4f commit ca69f51
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@

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

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

// XFAIL: LIBCXX-AIX-FIXME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@

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

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

// XFAIL: LIBCXX-AIX-FIXME

Expand Down
20 changes: 20 additions & 0 deletions libcxx/utils/libcxx/test/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,26 @@ def _mingwSupportsModules(cfg):
""",
),
),
# Check for a Windows UCRT bug (not fixed upstream yet).
# With UCRT, printf("%a", 0.0) produces "0x0.0000000000000p+0",
# while other C runtimes produce just "0x0p+0".
# https://developercommunity.visualstudio.com/t/Printf-formatting-of-float-as-hex-prints/1660844
Feature(
name="win32-broken-printf-a-precision",
when=lambda cfg: "_WIN32" in compilerMacros(cfg)
and not programSucceeds(
cfg,
"""
#include <stdio.h>
#include <string.h>
int main(int, char**) {
char buf[100];
snprintf(buf, sizeof(buf), "%a", 0.0);
return strcmp(buf, "0x0p+0");
}
""",
),
),
# Check for Glibc < 2.27, where the ru_RU.UTF-8 locale had
# mon_decimal_point == ".", which our tests don't handle.
Feature(
Expand Down
2 changes: 2 additions & 0 deletions libcxxabi/test/test_demangle.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// 80-bit format, and this demangling test is failing on it.
// XFAIL: LIBCXX-ANDROID-FIXME && target={{i686|x86_64}}-{{.+}}-android{{.*}}

// XFAIL: win32-broken-printf-a-precision

#include "support/timer.h"
#include <algorithm>
#include <cassert>
Expand Down

0 comments on commit ca69f51

Please sign in to comment.