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

STYLE: Prefer c++17 [[maybe_unused]] attribute over (void) #4581

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

hjmjohnson
Copy link
Member

@hjmjohnson hjmjohnson commented Apr 12, 2024

The use of (void)varname was a mechanism to silence compiler warnings prior to universal language support in c++17 for the [[maybe_unused]] attribute specifier.

PR Checklist

@hjmjohnson hjmjohnson added the type:Style Style changes: no logic impact (indentation, comments, naming) label Apr 12, 2024
@hjmjohnson hjmjohnson self-assigned this Apr 12, 2024
@github-actions github-actions bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module area:Video Issues affecting the Video module area:Numerics Issues affecting the Numerics module labels Apr 12, 2024
@hjmjohnson hjmjohnson marked this pull request as draft April 12, 2024 10:28
@github-actions github-actions bot removed area:Segmentation Issues affecting the Segmentation module area:Video Issues affecting the Video module labels Apr 12, 2024
@hjmjohnson hjmjohnson marked this pull request as ready for review April 13, 2024 13:14
@hjmjohnson
Copy link
Member Author

@thewtex -- This PR is getting old, and is one that will likely have merge-conflicts. Is this one that can be merged at this point?

Copy link
Member

@blowekamp blowekamp left a comment

Choose a reason for hiding this comment

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

I noted the two cases I saw, where the void maybe used to prevent a variable from being optimized away. Although I was not able reproduce this scenario, I am hesitant to merged those changes right before the release.

If those two cases were separated into another PR, I think this PR is OK, if @thewtex is OK with it and the release schedual.

@hjmjohnson
Copy link
Member Author

@blowekamp I'll wait until next month after the release. Hopefully, there won't be too many merge conflicts.

@hjmjohnson hjmjohnson added this to the ITK 6.0.0 milestone Apr 30, 2024
@hjmjohnson hjmjohnson marked this pull request as draft April 30, 2024 13:30
@hjmjohnson
Copy link
Member Author

Making a draft until until after 5.4 release is complete.

@hjmjohnson hjmjohnson modified the milestones: ITK 6.0.0, ITK 6.0 Beta 1 Apr 30, 2024
@thewtex
Copy link
Member

thewtex commented Apr 30, 2024

Thank you for saving this improvement for after v5.4.0 👍

@seanm
Copy link
Contributor

seanm commented May 6, 2024

Isn't [[maybe_unused]] C++17, not C++11?

@thewtex
Copy link
Member

thewtex commented May 20, 2024

@hjmjohnson v5.4.0 has been tagged -- please merge when you see fit.

The use of (void)varname was a mechanism to silence compiler
warnings prior to universal language support in c++17 for
the [[maybe_unused]] attribute specifier.
Function signature variable names are preserved using
itkNotUsed macro for documentation purposes.
Prefer to test input values are correct rather than
ignore the unused variable.
@hjmjohnson hjmjohnson changed the title STYLE: Prefer c++11 [[maybe_unused]] attribute over (void) STYLE: Prefer c++17 [[maybe_unused]] attribute over (void) May 31, 2024
@hjmjohnson
Copy link
Member Author

Isn't [[maybe_unused]] C++17, not C++11?

Updated comments.

@hjmjohnson hjmjohnson requested a review from blowekamp May 31, 2024 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Numerics Issues affecting the Numerics module area:Registration Issues affecting the Registration module type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Style Style changes: no logic impact (indentation, comments, naming) type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants