[libcxx-commits] [PATCH] D128146: [libc++] Use uninitialized algorithms for vector
Evgeny Eltsin via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 2 10:35:08 PDT 2022
eaeltsin added a comment.
Here is a sample that was compiling Ok before the change and is now broken: https://godbolt.org/z/djPG94f69
#include <vector>
template <typename B>
struct REAL_TYPEDEF {
typedef B base_type;
B v;
REAL_TYPEDEF() : v(0){}
explicit REAL_TYPEDEF(B v) : v(v){}
inline bool operator==(const REAL_TYPEDEF<B>& rhs) const {
return v == rhs.v;
}
};
template <typename T>
inline bool operator!=(const T& lhs, const T& rhs) {
return !(lhs == rhs);
}
namespace zim {
typedef int offset_type;
#define TYPEDEF(NAME, TYPE) \
struct NAME : public REAL_TYPEDEF<TYPE> { \
explicit NAME(TYPE v = 0) : REAL_TYPEDEF<TYPE>(v){} \
}; \
static_assert(sizeof(NAME) == sizeof(TYPE), "");
TYPEDEF(offset_t, offset_type)
int foo(int n) {
std::vector<offset_t> b;
b.reserve(n);
return b.size();
}
}; // namespace zim
New output:
In file included from <source>:1:
In file included from /opt/compiler-explorer/clang-trunk-20220802/bin/../include/c++/v1/vector:296:
In file included from /opt/compiler-explorer/clang-trunk-20220802/bin/../include/c++/v1/__split_buffer:24:
In file included from /opt/compiler-explorer/clang-trunk-20220802/bin/../include/c++/v1/memory:858:
In file included from /opt/compiler-explorer/clang-trunk-20220802/bin/../include/c++/v1/__memory/ranges_uninitialized_algorithms.h:22:
/opt/compiler-explorer/clang-trunk-20220802/bin/../include/c++/v1/__memory/uninitialized_algorithms.h:628:21: error: use of overloaded operator '!=' is ambiguous (with operand types 'std::reverse_iterator<zim::offset_t *>' and 'std::reverse_iterator<zim::offset_t *>')
while (__first1 != __last1) {
~~~~~~~~ ^ ~~~~~~~
/opt/compiler-explorer/clang-trunk-20220802/bin/../include/c++/v1/vector:914:27: note: in instantiation of function template specialization 'std::__uninitialized_allocator_move_if_noexcept<std::allocator<zim::offset_t>, std::reverse_iterator<zim::offset_t *>, std::reverse_iterator<zim::offset_t *>, zim::offset_t, void>' requested here
__v.__begin_ = std::__uninitialized_allocator_move_if_noexcept(
^
/opt/compiler-explorer/clang-trunk-20220802/bin/../include/c++/v1/vector:1501:9: note: in instantiation of member function 'std::vector<zim::offset_t>::__swap_out_circular_buffer' requested here
__swap_out_circular_buffer(__v);
^
<source>:35:5: note: in instantiation of member function 'std::vector<zim::offset_t>::reserve' requested here
b.reserve(n);
^
/opt/compiler-explorer/clang-trunk-20220802/bin/../include/c++/v1/__iterator/reverse_iterator.h:233:1: note: candidate function [with _Iter1 = zim::offset_t *, _Iter2 = zim::offset_t *]
operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
^
<source>:16:13: note: candidate function [with T = std::reverse_iterator<zim::offset_t *>]
inline bool operator!=(const T& lhs, const T& rhs) {
^
1 error generated.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128146/new/
https://reviews.llvm.org/D128146
More information about the libcxx-commits
mailing list