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

Merged

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 force-pushed the prefer-maybe-unused branch from 7f8732a to 017193a Compare April 12, 2024 02:22
@hjmjohnson hjmjohnson marked this pull request as draft April 12, 2024 10:28
@hjmjohnson hjmjohnson force-pushed the prefer-maybe-unused branch from 017193a to d69c780 Compare April 12, 2024 17:14
@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 force-pushed the prefer-maybe-unused branch from d69c780 to e773540 Compare April 12, 2024 20:27
@hjmjohnson hjmjohnson marked this pull request as ready for review April 13, 2024 13:14
@hjmjohnson hjmjohnson force-pushed the prefer-maybe-unused branch from e749cae to 1938221 Compare April 13, 2024 13:18
@hjmjohnson hjmjohnson requested a review from N-Dekker April 14, 2024 21:29
@hjmjohnson hjmjohnson force-pushed the prefer-maybe-unused branch from 1938221 to 3856b89 Compare April 17, 2024 00:44
@hjmjohnson hjmjohnson requested a review from N-Dekker April 29, 2024 17:24
@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?

@hjmjohnson hjmjohnson requested a review from blowekamp April 29, 2024 18:06
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.

@hjmjohnson hjmjohnson force-pushed the prefer-maybe-unused branch 2 times, most recently from 02c188a to 6582d65 Compare May 31, 2024 14:41
@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
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 marked this pull request as ready for review June 6, 2024 16:28
@hjmjohnson hjmjohnson force-pushed the prefer-maybe-unused branch from 6582d65 to a7b4d14 Compare June 6, 2024 16:29
Copy link
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

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

🔢

@hjmjohnson hjmjohnson merged commit 69738a9 into InsightSoftwareConsortium:master Jun 6, 2024
13 checks passed
@hjmjohnson hjmjohnson deleted the prefer-maybe-unused branch June 6, 2024 21:24
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.

5 participants