abseil / abseil/abseil-cpp

StrSplit return as std::set/absl::flat_hash_set triggers warning

Đang mở
#1,233 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
question
Ngôn ngữ chính
C++
Star
18.1k
Fork
3.2k
Merge trung bình
20 giờ 36 phút
Pull request đã merge (30 ngày)
1

Mô tả

I'm currently using Abseil-app from the master branch. My code:
```c++
std::set controllers = absl::StrSplit(*content, ' '); // content: absl::StatusOr
```
Would trigger:
```shell
In file included from /home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/strings/str_split.h:48,
from /home/parallels/weiran-dev/rouster/src/main.cpp:11:
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h: In instantiation of ‘absl::strings_internal::SplitIterator& absl::strings_internal::SplitIterator::operator++() [with Splitter = absl::strings_internal::Splitter >]’:
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h:321:7: required from ‘Container absl::strings_internal::Splitter::ConvertToContainer::operator()(const absl::strings_internal::Splitter&) const [with Container = std::set >; ValueType = std::__cxx11::basic_string; bool is_map = false; Delimiter = absl::ByChar; Predicate = absl::AllowEmpty; StringType = std::basic_string_view]’
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h:288:65: required from ‘absl::strings_internal::Splitter::operator Container() const [with Container = std::set >; = void; Delimiter = absl::ByChar; Predicate = absl::AllowEmpty; StringType = std::basic_string_view]’
/home/parallels/weiran-dev/rouster/src/main.cpp:54:71: required from here
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h:135:42: warning: conversion to ‘std::basic_string_view::size_type’ {aka ‘long unsigned int’} from ‘long int’ may change the sign of the result [-Wsign-conversion]
135 | curr_ = text.substr(pos_, d.data() - (text.data() + pos_));
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
```
And `absl::flat_hash_set` will trigger additional warnings (besides the above warning):
```shell
In file included from /home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h:40,
from /home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/container/internal/inlined_vector.h:30,
from /home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/container/inlined_vector.h:53,
from /home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/status/status.h:57,
from /home/parallels/weiran-dev/rouster/src/linux/sys.h:1,
from /home/parallels/weiran-dev/rouster/src/container.hpp:12,
from /home/parallels/weiran-dev/rouster/src/main.cpp:6:
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/utility/utility.h: In instantiation of ‘T absl::exchange(T&, U&&) [with T = long unsigned int; U = int]’:
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h:1275:29: required from ‘absl::container_internal::raw_hash_set::raw_hash_set(absl::container_internal::raw_hash_set&&) [with Policy = absl::container_internal::FlatHashSetPolicy >; Hash = absl::container_internal::StringHash; Eq = absl::container_internal::StringEq; Alloc = std::allocator >]’
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/container/flat_hash_set.h:105:7: required from ‘Container absl::strings_internal::Splitter::ConvertToContainer::operator()(const absl::strings_internal::Splitter&) const [with Container = absl::flat_hash_set >; ValueType = std::basic_string_view; bool is_map = false; Delimiter = absl::ByChar; Predicate = absl::AllowEmpty; StringType = std::basic_string_view]’
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h:288:65: required from ‘absl::strings_internal::Splitter::operator Container() const [with Container = absl::flat_hash_set >; = void; Delimiter = absl::ByChar; Predicate = absl::AllowEmpty; StringType = std::basic_string_view]’
/home/parallels/weiran-dev/rouster/src/main.cpp:54:87: required from here
/home/parallels/weiran-dev/rouster/third_party/abseil-cpp/absl/utility/utility.h:316:7: warning: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
316 | obj = absl::forward(new_value);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Seems like there exist some implicit conversions. Though these are not errors, can we have a fix for them?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.