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

[BUG] DoNotOptimize(T &&) should not be deprecated #1584

Closed
davidstone opened this issue Apr 9, 2023 · 2 comments · Fixed by #1608
Closed

[BUG] DoNotOptimize(T &&) should not be deprecated #1584

davidstone opened this issue Apr 9, 2023 · 2 comments · Fixed by #1608

Comments

@davidstone
Copy link

Describe the bug

In #1493, the T const & overload of DoNotOptimize was deprecated because the compiler is still able to make assumptions about the value of the variable. However, it is unclear whether this concern would apply to an rvalue reference overload.

To reproduce

int f() {
    return 5;
}
void g() {
    benchmark::DoNotOptimize(f());
}

Expected behavior

No warning is emitted.

@dmah42
Copy link
Member

dmah42 commented Apr 11, 2023

@ckennelly is the expert. i defer to them.

@horenmar
Copy link

horenmar commented Jun 4, 2023

Bumping this because I share @davidstone's opinion and also because I have to deal with about 50 warnings caused by this change.

bgaifullin added a commit to bgaifullin/benchmark that referenced this issue Jun 12, 2023
dmah42 pushed a commit that referenced this issue Jun 19, 2023
* Fix pass rvalue to DoNotOptimize #1584

* Add test
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 a pull request may close this issue.

3 participants