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

Add LL suffix to avoid c4307 #118

Merged
merged 1 commit into from
Sep 13, 2018
Merged

Add LL suffix to avoid c4307 #118

merged 1 commit into from
Sep 13, 2018

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented Sep 12, 2018

MSVC will warn with code C4307 and calculate an unintended value if the result of RCUTILS_S_TO_NS is greater than 32bits. As far as I can tell this is because 1000 is small enough to fit in an int so that becomes its type according to https://en.cppreference.com/w/cpp/language/integer_literal . MSVC says the size of int is 4 bytes even on 64bit platforms https://msdn.microsoft.com/en-us/library/s3f49ktz.aspx. In the RCUTILS_S_TO_NS case this means that seconds * 1000 * 1000 * 1000 is done using 32bit math and will overflow when seconds is greater than 2.

@sloretz sloretz added the in review Waiting for review (Kanban column) label Sep 12, 2018
@sloretz sloretz self-assigned this Sep 12, 2018
@sloretz
Copy link
Contributor Author

sloretz commented Sep 12, 2018


Edit, actually CI isn't crowded right now. Running full CI

* Linux [![Build Status](http://ci.ros2.org/buildStatus/icon?job=ci_linux&build=5169)](http://ci.ros2.org/job/ci_linux/5169/)
* Linux-aarch64 [![Build Status](http://ci.ros2.org/buildStatus/icon?job=ci_linux-aarch64&build=1943)](http://ci.ros2.org/job/ci_linux-aarch64/1943/)
* macOS [![Build Status](http://ci.ros2.org/buildStatus/icon?job=ci_osx&build=4294)](http://ci.ros2.org/job/ci_osx/4294/)
* Windows [![Build Status](http://ci.ros2.org/buildStatus/icon?job=ci_windows&build=5150)](http://ci.ros2.org/job/ci_windows/5150/)

@sloretz sloretz merged commit 660e090 into master Sep 13, 2018
@sloretz sloretz removed the in review Waiting for review (Kanban column) label Sep 13, 2018
@sloretz sloretz deleted the LL_constants branch September 13, 2018 00:25
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 this pull request may close these issues.

3 participants