[libcxx-commits] [PATCH] D128146: [libc++] Use uninitialized algorithms for vector
Nico Weber via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jul 29 10:23:30 PDT 2022
thakis added a comment.
Hello, this changes behavior for the following program. Is that intentional? (It has an easy workaround -- just remove that defaulted ctor, and we only hit it in a single place as far as I know, so it's not a big problem for us -- but I thought I'd check if the change in behavior is intentional)
$ cat test.cc
#include <vector>
class Instruction {
public:
int i;
};
class StructuredControlState {
public:
StructuredControlState(Instruction* break_merge, Instruction* merge)
: break_merge_(break_merge), current_merge_(merge) {}
StructuredControlState(const StructuredControlState&) = default;
bool InBreakable() const { return break_merge_; }
bool InStructuredFlow() const { return CurrentMergeId() != 0; }
uint32_t CurrentMergeId() const;
uint32_t CurrentMergeHeader() const;
uint32_t BreakMergeId() const;
Instruction* BreakMergeInst() const { return break_merge_; }
private:
Instruction* break_merge_;
Instruction* current_merge_;
};
class MergeReturnPass {
void GenerateState() {
Instruction inst;
v.emplace_back(&inst, &inst);
}
std::vector<StructuredControlState> v;
};
Before this change:
$ third_party/llvm-build/Release+Asserts/bin/clang -I buildtools/third_party/libc++/trunk/include/ -c test.cc -I buildtools/third_party/libc++ -nostdinc++ -std=c++17 -Wall -Wdeprecated-copy
# fine
After this change:
$ third_party/llvm-build/Release+Asserts/bin/clang -I buildtools/third_party/libc++/trunk/include/ -c test.cc -I buildtools/third_party/libc++ -nostdinc++ -std=c++17 -Wall -Wdeprecated-copy
test.cc:11:3: warning: definition of implicit copy assignment operator for 'StructuredControlState' is deprecated because it has a user-declared copy constructor [-Wdeprecated-copy]
StructuredControlState(const StructuredControlState&) = default;
^
buildtools/third_party/libc++/trunk/include/__algorithm/move.h:33:15: note: in implicit copy assignment operator for 'StructuredControlState' first required here
*__result = std::move(*__first);
^
buildtools/third_party/libc++/trunk/include/__algorithm/move.h:52:17: note: in instantiation of function template specialization 'std::__move_impl<StructuredControlState *, StructuredControlState *, StructuredControlState *>' requested here
return std::__move_impl<_InType*, _InType*, _OutType*>(__first, __last, __result);
^
buildtools/third_party/libc++/trunk/include/__algorithm/move.h:84:8: note: in instantiation of function template specialization 'std::__move_impl<StructuredControlState, StructuredControlState, void>' requested here
std::__move_impl(__last_base, __first_base, __result_first);
^
buildtools/third_party/libc++/trunk/include/__algorithm/move.h:94:21: note: in instantiation of function template specialization 'std::__move_impl<StructuredControlState *, StructuredControlState *, 0>' requested here
auto __ret = std::__move_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result));
^
buildtools/third_party/libc++/trunk/include/__algorithm/move.h:110:15: note: in instantiation of function template specialization 'std::__move<std::reverse_iterator<StructuredControlState *>, std::reverse_iterator<StructuredControlState *>, std::reverse_iterator<StructuredControlState *>>' requested here
return std::__move(__first, __last, __result).second;
^
buildtools/third_party/libc++/trunk/include/__memory/uninitialized_algorithms.h:635:17: note: in instantiation of function template specialization 'std::move<std::reverse_iterator<StructuredControlState *>, std::reverse_iterator<StructuredControlState *>>' requested here
return std::move(__first1, __last1, __first2);
^
buildtools/third_party/libc++/trunk/include/vector:914:27: note: in instantiation of function template specialization 'std::__uninitialized_allocator_move_if_noexcept<std::allocator<StructuredControlState>, std::reverse_iterator<StructuredControlState *>, std::reverse_iterator<StructuredControlState *>, StructuredControlState, void>' requested here
__v.__begin_ = std::__uninitialized_allocator_move_if_noexcept(
^
buildtools/third_party/libc++/trunk/include/vector:1581:5: note: in instantiation of member function 'std::vector<StructuredControlState>::__swap_out_circular_buffer' requested here
__swap_out_circular_buffer(__v);
^
buildtools/third_party/libc++/trunk/include/vector:1600:9: note: in instantiation of function template specialization 'std::vector<StructuredControlState>::__emplace_back_slow_path<Instruction *, Instruction *>' requested here
__emplace_back_slow_path(_VSTD::forward<_Args>(__args)...);
^
test.cc:25:7: note: in instantiation of function template specialization 'std::vector<StructuredControlState>::emplace_back<Instruction *, Instruction *>' requested here
v.emplace_back(&inst, &inst);
^
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