Skip to content

Commit bdcaddd

Browse files
authored
fix conversion to ‘std::streamsize’ {aka ‘long int’} from ‘size_t’ {aka ‘long unsigned int’} may change the sign of the result (ros2#715)
Signed-off-by: Grzegorz Głowacki <[email protected]>
1 parent 0894a84 commit bdcaddd

File tree

1 file changed

+2
-1
lines changed
  • rosidl_runtime_cpp/include/rosidl_runtime_cpp

1 file changed

+2
-1
lines changed

rosidl_runtime_cpp/include/rosidl_runtime_cpp/traits.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <codecvt>
1919
#include <iomanip>
20+
#include <iosfwd>
2021
#include <string>
2122
#include <type_traits>
2223

@@ -114,7 +115,7 @@ inline void value_to_yaml(const std::string & value, std::ostream & out)
114115
if (pos == std::string::npos) {
115116
pos = value.size();
116117
}
117-
out.write(&value[index], pos - index);
118+
out.write(&value[index], static_cast<std::streamsize>(pos - index));
118119
if (pos >= value.size()) {
119120
break;
120121
}

0 commit comments

Comments
 (0)