Skip to content

Forward arguments to BoutException and Output::write#3224

Merged
ZedThree merged 3 commits into
nextfrom
forward-exception-args
Dec 5, 2025
Merged

Forward arguments to BoutException and Output::write#3224
ZedThree merged 3 commits into
nextfrom
forward-exception-args

Conversation

@ZedThree
Copy link
Copy Markdown
Member

@ZedThree ZedThree commented Dec 4, 2025

This enables passing views like fmt::join which otherwise fail with:

error: static assertion failed: passing views as lvalues is disallowed

Very simple fix: change the argument types to Args&&... (universal forwarding
reference) and call std::forward.

Plus some drive-by clang-tidy fixes.

ZedThree and others added 3 commits December 4, 2025 18:04
This enables passing views like `fmt::join` which otherwise fail with:

```
error: static assertion failed: passing views as lvalues is disallowed
```
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread src/sys/boutexception.cxx
Dl_info info;
void* ptr = trace[i];
if (dladdr(trace[i], &info)) {
const void* ptr = trace[i];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use array subscript when the index is not an integer constant expression [cppcoreguidelines-pro-bounds-constant-array-index]

    const void* ptr = trace[i];
                      ^

Comment thread src/sys/boutexception.cxx
// Additionally, check whether this is the default offset for an executable
if (info.dli_fbase != reinterpret_cast<void*>(0x400000)) {
ptr = reinterpret_cast<void*>(reinterpret_cast<size_t>(trace[i])
ptr = reinterpret_cast<void*>(reinterpret_cast<size_t>(ptr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast]

        ptr = reinterpret_cast<void*>(reinterpret_cast<size_t>(ptr)
                                      ^

Comment thread src/sys/boutexception.cxx
// Additionally, check whether this is the default offset for an executable
if (info.dli_fbase != reinterpret_cast<void*>(0x400000)) {
ptr = reinterpret_cast<void*>(reinterpret_cast<size_t>(trace[i])
ptr = reinterpret_cast<void*>(reinterpret_cast<size_t>(ptr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast]

        ptr = reinterpret_cast<void*>(reinterpret_cast<size_t>(ptr)
              ^

Comment thread src/sys/boutexception.cxx
// Additionally, check whether this is the default offset for an executable
if (info.dli_fbase != reinterpret_cast<void*>(0x400000)) {
ptr = reinterpret_cast<void*>(reinterpret_cast<size_t>(trace[i])
ptr = reinterpret_cast<void*>(reinterpret_cast<size_t>(ptr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]

        ptr = reinterpret_cast<void*>(reinterpret_cast<size_t>(ptr)
              ^

Copy link
Copy Markdown
Contributor

@dschwoerer dschwoerer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup!

Comment thread src/sys/boutexception.cxx
@ZedThree ZedThree merged commit fc15ca8 into next Dec 5, 2025
1 check passed
@ZedThree ZedThree deleted the forward-exception-args branch December 5, 2025 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants