Some way to support an a handler for `BOOST_ASSERT(_MSG)` that takes a `std::source_location`
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- cpp
- Domain
- testing-qa
Research direction
Start by reviewing the existing BOOST_ASSERT handler API and how BOOST_ASSERT(_MSG) expands. Compare the proposed std::source_location handler option with the customizable BOOST_ASSERT_FAILURE_HANDLER() and BOOST_ASSERT_MSG_FAILURE_HANDLER() macros. Done requires a maintainer-approved API design and corresponding implementation scope.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C++
- Stars
- 35
- Forks
- 77
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/assert
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·