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

Compilation warning related to strict-aliasing rules #15

Open
traversaro opened this issue Apr 27, 2021 · 3 comments
Open

Compilation warning related to strict-aliasing rules #15

traversaro opened this issue Apr 27, 2021 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@traversaro
Copy link
Member

The compilation has the device raise this interesting warning:

1266 |             b = optionValue2Perc(RS2_OPTION_EXPOSURE, m_color_sensor, (float&) value, valToGet);
      |                                                                                ^~~~~
../src/devices/realsense2/realsense2Driver.cpp:1270:76: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 1270 |             b = optionValue2Perc(RS2_OPTION_GAIN, m_color_sensor, (float&) value, valToGet);
      |                                                                            ^~~~~
../src/devices/realsense2/realsense2Driver.cpp:1280:85: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 1280 |             b = optionValue2Perc(RS2_OPTION_WHITE_BALANCE, m_color_sensor, (float&) value, valToGet);
      |                                                                                     ^~~~~
../src/devices/realsense2/realsense2Driver.cpp:1284:81: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 1284 |             b = optionValue2Perc(RS2_OPTION_SHARPNESS, m_color_sensor, (float&) value, valToGet);
      |                                                                                 ^~~~~
../src/devices/realsense2/realsense2Driver.cpp:1288:75: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 1288 |             b = optionValue2Perc(RS2_OPTION_HUE, m_color_sensor, (float&) value, valToGet);
      |                                                                           ^~~~~
../src/devices/realsense2/realsense2Driver.cpp:1292:82: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 1292 |             b = optionValue2Perc(RS2_OPTION_SATURATION, m_color_sensor, (float&) value, valToGet);
      |            

Not sure if anyone is interested in fixing it, but I open an issue to track it.

@traversaro traversaro added the help wanted Extra attention is needed label Apr 27, 2021
@ste93
Copy link
Contributor

ste93 commented May 31, 2021

An option that seems to work is:

  • to edit the optionValue2Perc function as static bool optionValue2Perc(rs2_option option,const rs2::sensor* sensor, double* perc, const float& value)
  • and to pass value instead of (float&) value

@ste93
Copy link
Contributor

ste93 commented May 31, 2021

then row 217 must be a *perc = ...

@traversaro
Copy link
Member Author

Feel free to open a PR if you like, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants