Some way to support an a handler for `BOOST_ASSERT(_MSG)` that takes a `std::source_location`

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

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
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
cpp
Lĩnh vực
testing-qa

Hướng nghiên cứu

Bắt đầu bằng việc xem xét API handler BOOST_ASSERT hiện có và cách BOOST_ASSERT(_MSG) được mở rộng. So sánh tùy chọn handler std::source_location được đề xuất với các macro có thể tùy chỉnh BOOST_ASSERT_FAILURE_HANDLER() và BOOST_ASSERT_MSG_FAILURE_HANDLER(). Công việc được xem là hoàn tất khi có thiết kế API được maintainer phê duyệt và phạm vi triển khai tương ứng.

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

Mô tả

Problem: Using std::source_location is more efficient than passing separate file/line/column/func info because the location is a single pointer to static storage, rather than 2 pointer + 2 const ints. That can result in codegen bloat, especially on platforms like Aarch64 where it takes multiple instructions to load a global pointer. Given the usecase of assertions, this is often used for very cold (hopefully never executed!) code that sits in the same function as hot code, so you often want to make it as small as possible to maximize icache and iTLB. Note that it is important to use source_location from std:: rather than boost:: because the std:: flavor uses implementation techniques that are not available to userspace C++ to make it a single pointer to static storage.

Possible solution 1: Add a new macro like BOOST_ENABLE_ASSERT_HANDLER_WITH_STD_SOURCE_LOCATION to opt into a different handler API that takes std::source_location.

Possible solution 2: Give the user full control over the handler expression by just making the failure case be a macro call like BOOST_ASSERT_FAILURE_HANDLER() and BOOST_ASSERT_MSG_FAILURE_HANDLER(msg). The only tricky issue is that you would likely need some way to inject declarations and #includes into global scope, but it may be reasonable to say that anyone who can use this facility correctly can probably also use -include "my_boost_assert_prefix_header.h". This option also has the advantage for anyone who wants to use __builtin_trap() to get the ultimate code size reduction, while still checking asserts.

Ngôn ngữ chính
C++
Star
35
Fork
77
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

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 boostorg/assert

Tất cả issue của boostorg/assert

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.