-
Notifications
You must be signed in to change notification settings - Fork 0
Bug fix variable 'actual_iterations' set but not used (#1517) #3
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
Conversation
* Bug fix variable 'actual_iterations' set but not used Compiling the project in clang 15 without -Wno-unused-but-set-variable flag the following error is generated: benchmark-src/test/options_test.cc:70:10: error: variable 'actual_iterations' set but not used [-Werror,-Wunused-but-set-variable] size_t actual_iterations = 0; ^ * Adjust according formatting of `clang-format` Co-authored-by: dominic hamon <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK; seem fine. Though I reckon since we are 2
years old:
I wonder if we should just use the official repo. The only reason I have a commit had to do with CSMLTestRunner also linked with Benchmark. Now that is no longer the case I reckon we could use the official repo again.
But oh well; I am OK with these changes 👍 😃
It definitely needs to be updated soon. I just didn't have time to deal with any fallout of that today. Thanks for the review! |
@@ -67,8 +67,8 @@ void BM_explicit_iteration_count(benchmark::State& state) { | |||
|
|||
// Test that the requested iteration count is respected. | |||
assert(state.max_iterations == 42); | |||
size_t actual_iterations = 0; | |||
for (auto _ : state) ++actual_iterations; | |||
for (auto _ : state) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this loop is not doing anything, is it? Is this something we want in the future? If so using a maybe_unused
instead of deleting the variable maybe the way to go. Or get rid of this code entirely, given that it is not doing anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, that's how they should have fixed it, and it's how I fixed it locally when I first encountered this. I am picking the upstream commit intentionally instead of doing that, though, so that when we update the fork, we won't have a conflict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am under the assumption that the variable named underscore (_
) is iterating over the state
collection. Yes the body of the for
-loop is empty and thus you may believe it isn't doing anything. But just looping is doing something. Like it is probably something like:
auto it = state.begin();
while( it != state.end() ) it++;
So I do believe it wouldn't make sense to get rid of the for
-loop completely as it might actually be doing something.
Hope that helps some 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but unless there is some really weird behavior attached to the operator++
then that loop does not do anything. Maybe the State copy constructor does something really weird as well. Otherwise we are just assigning each element of state
to a temporary. Weird code.
Description
Pick bug fix from upstream repo for the this error we keep getting when compiling all of CommonCpp on Mac.
Upstream commit: google@62edc4f
Error
Original description from upstream commit