Add -Wconversion flag to protect future developments (backport #1053) #1815
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When working on
joint_limits
, I faced an issue with arclcpp::Duration
that I constructed using seconds and nanoseconds, but by mistake used afloat 0.005
for the seconds. Since the awaited arguments areints
, thefloat
conversion led to a NULL duration which I did not realize for a too long time.There was no compilation warning, as
-Wall
does not include-Wconversion
, supposedly to avoid too many warnings.With that flag the warning looks like this
I tested in
ros_control
package to add-Wconversion
compilation flag which created only 2 warnings, that could be easily fixed with explicit cast.Hence, for protecting future developments from risky mistakes with conversions, I suggest to add this flag in all packages of the repo. I will provide a similar PR for
ros2_controllers
that were definitively affected by exactly the same Time-at-zero issue.This is an automatic backport of pull request #1053 done by [Mergify](https://mergify.com).