Skip to content

Commit a53aa68

Browse files
committed
tests(math): include <future> before imports under _MSC_VER in doc_numerics
Reordering math before std was not enough for doc_numerics.cpp on windows-llvm-msvc (llvm@23.1.3): naive_monte_carlo still hit the MSVC ppltasks _GetStaticAmbientSchedulerRef static-split SIGSEGV (llvm/llvm-project#221548). Including <future> before the module imports under _MSC_VER gives the TU a single local definition before either PCM is loaded.
1 parent cc84f59 commit a53aa68

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎.agents/docs/todos/module-tests-open-issues.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
- [ ] **windows-llvm-msvc 上两个 clang 模块缺陷的绕过**(原因见
77
[记录](../2026-11-18-windows-msvc-module-crashes-analysis.md))。llvm/llvm-project#114075 合入后,删去
88
`tools/port_tests/helpers/asio.hpp`(及重新生成的 `tests/asio/*.cpp`)与 `tests/cobalt/doc.cpp` 中补全
9-
CatchableType 的 throw;ppltasks 局部静态变量合并的缺陷修好后,`tests/math/doc_sf.cpp` 与
10-
`tests/math/doc_numerics.cpp` 可恢复 `import std` 在前。两处都要在 Windows 上确认。
9+
CatchableType 的 throw;ppltasks 局部静态变量合并的缺陷修好后,`tests/math/doc_sf.cpp` 可恢复
10+
`import std` 在前,`tests/math/doc_numerics.cpp` 可删去 `_MSC_VER` 下的 `#include <future>`。两处都要在 Windows 上确认。
1111
- [x] **aarch64 Linux 上 `ooura_fourier_cos<double>` 返回 NaN**:上游问题,与封装层无关。该腿以
1212
musl 为 C 库,musl 的 113 位 `expl`/`expm1l`/`log1pl` 直接调用 `double` 版本,最后一个小节点上
1313
`exp(-eta)` 溢出成 `inf`,权重成为 NaN 而节点为 0,被收入求和;sine 版因 `node <= 0` 即停而不受影响。

‎tests/math/doc_numerics.cpp‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@
66
// known answer.
77
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
88
#include <doctest/doctest.h>
9-
// math before std: see tests/math/doc_sf.cpp (with std imported first on
10-
// windows-llvm-msvc, clang merges MSVC's ppltasks _GetStaticAmbientSchedulerRef
11-
// into two copies of its static so std::async in naive_monte_carlo /
12-
// daubechies_wavelet reads a null scheduler; llvm/llvm-project#221548).
13-
import mcpplibs.mwrap.boost.math;
9+
#ifdef _MSC_VER
10+
// MSVC's <future> (ppltasks) defines inline _GetStaticAmbientSchedulerRef with
11+
// a static pointer initialized in a call_once lambda. When both `std` and
12+
// `mcpplibs.mwrap.boost.math`'s GMF supply it, clang on windows-llvm-msvc can
13+
// split the static across the merged function and lambda
14+
// (llvm/llvm-project#221548), so std::async in naive_monte_carlo reads a null
15+
// scheduler regardless of import order. Including <future> first gives the TU
16+
// a single local definition before either module is imported.
17+
#include <future>
18+
#endif
1419
import std;
20+
import mcpplibs.mwrap.boost.math;
1521

1622
namespace bm = boost::math;
1723

0 commit comments

Comments
 (0)