`<cmath>`: `constexpr` `fpclassify()` rejects signaling NaNs on x86

Đang mở
#6,445 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@ayushsshukla đang làm issue này rồi.

Từ ngày 10/9/2026.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp
Lĩnh vực
compilers

Hướng nghiên cứu

Bắt đầu với trình tái hiện meow.cpp và chạy lệnh x86 cl được hiển thị bằng /std:c++latest và /Zc:cmath. Kiểm tra đường dẫn đánh giá constexpr được báo cáo qua __msvc_math.hpp:321 và xác định lý do signaling_NaN() gây ra ngoại lệ dấu phẩy động. Hoàn tất khi static_assert thành công trên x86 mà không gặp lỗi đánh giá hằng số này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug compiler

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'
Ngôn ngữ chính
C++
Star
11.2k
Fork
1.7k
Merge trung bình
4 ngày 4 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/STL

Tất cả issue của microsoft/STL

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.