Code behaves differently if compiled with MSVC vs GCC
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Tái hiện mẫu bằng MSVC 19 và GCC 12, sau đó so sánh include/boost/numeric/interval/detail/c99sub_rounding_control.hpp với include/boost/numeric/interval/detail/msvc_rounding_control.hpp. Xem xét cách mỗi nền tảng cấu hình việc làm tròn số dấu phẩy động và các cơ chế kiểm soát ngoại lệ, đồng thời xác định hành vi đa nền tảng dự kiến trước khi thay đổi một trong hai phần triển khai.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
VS 19 vs GCC 12
If you build and run the following sample with both compilers:
#include <fenv.h>
#include <iostream>
#pragma warning(push)
#pragma warning(disable : 4702)
#include <boost/numeric/interval.hpp>
#pragma warning(pop)
/// An interval of doubles [lower,upper)
using Interval = boost::numeric::interval<double,boost::numeric::interval_lib::policies<boost::numeric::interval_lib::rounded_math<double>,boost::numeric::interval_lib::checking_strict<double>>>;
/// An interval from -DBL_MAX to +DBL_MAX
const inline Interval InfiniteInterval =
Interval(std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max());
int main(void)
{
#ifdef _WIN32
unsigned int current_word = 0;
_controlfp_s(¤t_word, 0, _MCW_EM);
#else
feenableexcept(FE_ALL_EXCEPT);
#endif
auto i = InfiniteInterval;
boost::numeric::width(i);
std::cerr << "The end" << std::endl;
}
You will see how it fails with FP exception on linux, but never fails on windows.
The reason is simple:
On linux we adjust only rounding mode https://github.com/boostorg/interval/blob/2eda7413ac16dd4158005446438daf8a7e435dd9/include/boost/numeric/interval/detail/c99sub_rounding_control.hpp#L27
But on windows in addition to rounding we also mask all the FP exceptions (turn off corresponding flags) https://github.com/boostorg/interval/blob/2eda7413ac16dd4158005446438daf8a7e435dd9/include/boost/numeric/interval/detail/msvc_rounding_control.hpp#L93 because we use _MCW_EM | _MCW_RC instead of _MCW_RC only.
Shouldn't both systems set the same FP settings? If yes - what should they adjust? Both systems should adjust rounding only, or both should adjust rounding and exception masking?
If we only want to change rounding control bits - it is enough to remove _MCW_EM | part of that line and both systems will throw FP exception.
- Ngôn ngữ chính
- C++
- Star
- 31
- Fork
- 49
- Merge trung bình
- 1 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của boostorg/interval
-
Emscripten compilation issueĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
-
Cosine rounding failure on macOSĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Tất cả issue của boostorg/interval
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[WinReg] update to v12.0.0Đang mởcategory:port-update
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày
-
(S1 - Need confirmation)
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
CleverRaven/Cataclysm-DDA#89194 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
reproduced
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày