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

subchroma_image_view methods return reference to local temporary object #475

Closed
mloskot opened this issue Apr 6, 2020 · 3 comments · Fixed by #556
Closed

subchroma_image_view methods return reference to local temporary object #475

mloskot opened this issue Apr 6, 2020 · 3 comments · Fixed by #556
Labels
cat/bug But reports and bug fixes ext/toolbox boost/gil/extension/toolbox/ good-first-issue Opportunity for new contributors to help improving GIL
Milestone

Comments

@mloskot
Copy link
Member

mloskot commented Apr 6, 2020

Actual behavior

../../boost/gil/extension/toolbox/image_types/subchroma_image.hpp:248:49: warning: returning reference to local temporary object [-Wreturn-stack-address]
    const point_t& v_ssfactors() const { return point_t( get_deref_fn().vx_ssfactor(), get_deref_fn().vx_ssfactor() ); }
                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../boost/gil/extension/toolbox/image_types/subchroma_image.hpp:249:49: warning: returning reference to local temporary object [-Wreturn-stack-address]
    const point_t& u_ssfactors() const { return point_t( get_deref_fn().ux_ssfactor(), get_deref_fn().ux_ssfactor() ); }
                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expected behavior

C++ Minimal Working Example

$ cat test.cpp
#include <boost/gil/extension/toolbox//image_types/subchroma_image.hpp>
int main() {}

$ clang++-10 -std=c++11 -I/mnt/d/boost.wsl test.cpp

Environment

  • Version (Git ref or <boost/version.hpp>): 1.72 and current develop branch
  • Compiler: clang 3.9, 6, 7, ...
@mloskot mloskot added cat/bug But reports and bug fixes ext/toolbox boost/gil/extension/toolbox/ good-first-issue Opportunity for new contributors to help improving GIL labels Apr 6, 2020
@Scramjet911
Copy link
Contributor

Is this still an issue? I couldn't reproduce it on g++ 9.3 and c++11, all warnings enabled.

@mloskot
Copy link
Member Author

mloskot commented Jan 8, 2021

Is this still an issue?

The code in question has not changed.

I couldn't reproduce it on g++ 9.3

As given in the issue description, I reproduced it with clang.

@sdebionne
Copy link
Contributor

Isn't the fix as simple as returning by value instead of by reference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat/bug But reports and bug fixes ext/toolbox boost/gil/extension/toolbox/ good-first-issue Opportunity for new contributors to help improving GIL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants