-
Notifications
You must be signed in to change notification settings - Fork 3k
errors when building with -Wrange-loop-analysis option #787
Copy link
Copy link
Closed
envoyproxy/envoy
#13364Labels
Description
Describe the bug
When building with -Wrange-loop-analysis, abseil compilation fails with a few errors, for example:
external/com_google_absl/absl/strings/internal/str_split_internal.h:404:23: error: loop variable 'sp' of type 'const std::__1::basic_string_view<char, std::__1::char_traits<char> >' creates a copy from type 'const std::__1::basic_string_view<char, std::__1::char_traits<char> >' [-Werror,-Wrange-loop-analysis]
for (const auto sp : splitter) {
^
external/com_google_absl/absl/strings/internal/str_split_internal.h:305:12: note: in instantiation of member function 'absl::strings_internal::Splitter<absl::ByChar, absl::SkipEmpty>::ConvertToContainer<std::__1::map<std::__1::basic_string<char>, std::__1::basic_string<char>, std::__1::less<std::__1::basic_string<char> >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char>, std::__1::basic_string<char> > > >, std::__1::pair<const std::__1::basic_string<char>, std::__1::basic_string<char> >, true>::operator()' requested here
return ConvertToContainer<Container, typename Container::value_type,
^
source/extensions/filters/network/postgres_proxy/postgres_decoder.cc:360:17: note: in instantiation of function template specialization 'absl::strings_internal::Splitter<absl::ByChar, absl::SkipEmpty>::operator map<std::__1::map<std::__1::basic_string<char>, std::__1::basic_string<char>, std::__1::less<std::__1::basic_string<char> >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char>, std::__1::basic_string<char> > > >, void>' requested here
attributes_ = absl::StrSplit(message_.substr(4), absl::ByChar('\0'), absl::SkipEmpty());
^
external/com_google_absl/absl/strings/internal/str_split_internal.h:404:12: note: use reference type 'const std::__1::basic_string_view<char, std::__1::char_traits<char> > &' to prevent copying
for (const auto sp : splitter) {
^~~~~~~~~~~~~~~
This is currently being tracked in envoyproxy/envoy#13154 in Envoy.
Steps to reproduce the bug
- Enable
-Wrange-loop-analysisbuild option (enabled with Xcode 12) - Build
- We are experiencing this issue when building Envoy (build: enable -Wrange-loop-analysis rule envoyproxy/envoy#13184)
What version of Abseil are you using?
ce4bc927755fdf0ed03d679d9c7fa041175bb3cb (ref)
What operating system and version are you using
macOS 10.15.6
What compiler and version are you using?
Target: x86_64-apple-darwin19.6.0
Thread model: posix
What build system are you using?
bazel 3.4.1-homebrew
Additional context
N/A
Reactions are currently unavailable