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

Fix gcc 9 unused parameter error #5226

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

ikbuibui
Copy link
Contributor

Fix for the failing full CI run

@ikbuibui ikbuibui added the bug a bug in the project's code label Nov 25, 2024
@ikbuibui ikbuibui added this to the 0.8.0 / Next stable milestone Nov 25, 2024
Copy link
Member

@PrometheusPi PrometheusPi left a comment

Choose a reason for hiding this comment

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

looks okay
but do we need to add [[maybe_unused]] to line 62 too?

@ikbuibui
Copy link
Contributor Author

[[maybe_unused]] suppresses warnings about variables that might not be used in the current scope. This old compiler sees that the superCellIndex and eFieldBox are not used in the else branch of the if constexpr, so it throws a warning/error, even though they are conditionally used in the if branch on line 62.
[[maybe_unused]] isnt required on line 62 because it isnt defining any parameters which are later not used. It is only returning the cache. It is the responsibility of the caller of this function to store this cache and then use it. If the caller assigns the returned cache to a variable and then doesn't use it this warning/error will be thrown at the caller side.
Just for information, kind of similarly if you want to make sure that the return value of a function is stored (and not ignored/discarded) by the caller, you can declare the function [[nodiscard]].

@PrometheusPi
Copy link
Member

@ikbuibui Thanks for the clarification. Thant makes sense, I was following the documentation example here and was a bit confused.

@psychocoderHPC
Copy link
Member

Thanks @ikbuibui I planed to fix it too, good that I checked the PRs first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in the project's code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants