Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io_queue: fix static member access to comply with CWG2813 #2627

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

tchaikov
Copy link
Contributor

Fix build failure with recent Clang implementations of CWG2813, which makes accessing static members through instance expressions into discarded-value expressions. This caused nodiscard warnings when accessing static member tokens_capacity() through fgs[i].

Before:

  fgs[i].tokens_capacity()  // Warns: ignoring nodiscard return value

After:

  const auto& fg = fgs[i]); // not discarded
  fg.tokens_capacity();     // access static member function

Additionally, this refactoring reduces repetition of fgs[g_idx] expressions throughout the code.

See:

Fixes Scylla build failure with the latest Clang, as Scylla enables Seastar_UNUSED_RESULT_ERROR.

Fix build failure with recent Clang implementations of CWG2813, which
makes accessing static members through instance expressions into
discarded-value expressions. This caused nodiscard warnings when
accessing static member `tokens_capacity()` through `fgs[i]`.

Before:
```c++
  fgs[i].tokens_capacity()  // Warns: ignoring nodiscard return value
```

After:
```c++
  const auto& fg = fgs[i]); // not discarded
  fg.tokens_capacity();     // access static member function
```

Additionally, this refactoring reduces repetition of `fgs[g_idx]`
expressions throughout the code.

See:

- https://cplusplus.github.io/CWG/issues/2813.html
- https://eel.is/c++draft/expr.ref#2

Fixes Scylla build failure with the latest Clang, as Scylla enables
Seastar_UNUSED_RESULT_ERROR.

Signed-off-by: Kefu Chai <[email protected]>
@tchaikov tchaikov requested a review from xemul January 22, 2025 04:08
@tchaikov
Copy link
Contributor Author

see https://github.com/scylladb/scylladb/actions/runs/12442364586/job/34740406090 for an instance of the build failure.

@avikivity avikivity merged commit 1822136 into scylladb:master Jan 22, 2025
15 checks passed
@tchaikov tchaikov deleted the io_queue-CWG2813 branch January 22, 2025 21:15
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