ros2 / rmw_dds_common

Apache License 2.0
11 stars 20 forks source link

silence clang warning (`range-loop-construct`) #53

Closed Karsten1987 closed 3 years ago

Karsten1987 commented 3 years ago

I get warnings from clang when compiling the latest master:

/Users/karsten/workspace/ros2/ros2_master/src/ros2/rmw_dds_common/rmw_dds_common/src/security.cpp:38:52: error: loop variable 'el' has type 'const std::pair<std::string, std::string> &' (aka 'const pair<basic_string<char, char_traits<char>, allocator<char> >, basic_string<char, char_traits<char>, allocator<char> > > &') but is initialized with type 'const std::__1::__hash_map_const_iterator<std::__1::__hash_const_iterator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, std::__1::basic_string<char> >, void *> *> >::value_type' (aka 'const pair<const std::__1::basic_string<char>, std::__1::basic_string<char> >') resulting in a copy [-Werror,-Wrange-loop-construct]
  for (const std::pair<std::string, std::string> & el : required_files) {
                                                   ^
/Users/karsten/workspace/ros2/ros2_master/src/ros2/rmw_dds_common/rmw_dds_common/src/security.cpp:38:8: note: use non-reference type 'std::pair<std::string, std::string>' (aka 'pair<basic_string<char, char_traits<char>, allocator<char> >, basic_string<char, char_traits<char>, allocator<char> > >') to keep the copy or type 'const std::__1::__hash_map_const_iterator<std::__1::__hash_const_iterator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, std::__1::basic_string<char> >, void *> *> >::value_type &' (aka 'const pair<const std::__1::basic_string<char>, std::__1::basic_string<char> > &') to prevent copying
  for (const std::pair<std::string, std::string> & el : required_files) {
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Karsten1987 commented 3 years ago