`<cmath>`: `constexpr` `fpclassify()` rejects signaling NaNs on x86
维护者通常 2 天内回复
@ayushsshukla 已经在做这个了。
开始于 2026年9月10日。
评估
调研方向
从 meow.cpp 复现程序开始,使用 /std:c++latest 和 /Zc:cmath 运行所示的 x86 cl 命令。检查通过 __msvc_math.hpp:321 报告的 constexpr 求值路径,并确定 signaling_NaN() 导致浮点异常的原因。当 static_assert 在 x86 上能够成功通过且不再出现此常量求值失败时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
I could probably work around this in the library by using a bit_cast, but it would be better for the compiler to fix this bug.
D:\GitHub\STL\out\x86>cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.52.36725 for x86 (PREVIEW)
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
D:\GitHub\STL\out\x86>type meow.cpp
#include <cassert>
#include <cmath>
#include <limits>
#ifndef _M_IX86
static_assert(false, "Use x86 to repro this failure!");
#endif
constexpr bool test() {
assert(std::fpclassify(std::numeric_limits<double>::signaling_NaN()) == FP_NAN);
return true;
}
int main() {
static_assert(test());
}
D:\GitHub\STL\out\x86>cl /EHsc /nologo /W4 /std:c++latest /Zc:cmath meow.cpp
meow.cpp
meow.cpp(15): error C2131: expression did not evaluate to a constant
D:\GitHub\STL\out\x86\out\inc\__msvc_math.hpp(321): note: failure was caused by a library call raising a floating-point exception
meow.cpp(15): note: the call stack of the evaluation (the oldest call first) is
meow.cpp(15): note: while evaluating function 'bool test(void)'
meow.cpp(10): note: while evaluating function 'int _Msvc_math::fpclassify(double) noexcept'
- 主要语言
- C++
- 星标
- 11.2k
- 派生
- 1.7k
- 平均合并
- 4 天 4 小时
- 30 天内合并 PR
- 14
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/STL 的其他 Issue
-
LWG
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 2 天内回复
-
generator LWG
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 2 天内回复
-
LWG
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 2 天内回复
-
`<__msvc_math.hpp>`: `_USE_MATH_DEFINES` is ignored after the first `<math.h>` include under `/Zc:cmath`可能已有人在做 @tiagomacarios 于 10 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 2 天内回复
相似的 Issue
-
bug data-types
难度 2/5 1-3 小时 新手友好度 71/100
ClickHouse/clickhouse-odbc#680 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 76/100
ionut-mihalache/aqua#31 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
needs-kind
难度 2/5 1-3 小时 新手友好度 63/100
villagesql/villagesql-server#1702 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
microsoft/vcpkg-tool#2191 · 1 个 reaction ·
维护者通常 1 天内回复