Commit fa331472 authored by Hannes Roth's avatar Hannes Roth Committed by Sara Golemon

(Wangle) Possibly undefined behavior in collect

Summary: Not sure if this is really undefined behavior or whether UBSAN is just super paranoid. Will try to read up on it later.

I also changed some other `std::atomic` initialization to always follow the same pattern, let me know if I should revert those. I couldn't resist, OCD kicked in.

idonthaveocd

Reviewed By: @fugalh

Differential Revision: D2181074
parent cc89faa3
......@@ -600,7 +600,7 @@ struct CollectContext {
}
Promise<Result> p;
InternalResult result;
std::atomic<bool> threw;
std::atomic<bool> threw {false};
};
// Specialize for void (implementations in Future.cpp)
......@@ -660,9 +660,9 @@ collectAny(InputIterator first, InputIterator last) {
typename std::iterator_traits<InputIterator>::value_type::value_type T;
struct CollectAnyContext {
CollectAnyContext(size_t n) : done(false) {};
CollectAnyContext(size_t n) {};
Promise<std::pair<size_t, Try<T>>> p;
std::atomic<bool> done;
std::atomic<bool> done {false};
};
auto ctx = std::make_shared<CollectAnyContext>(std::distance(first, last));
......@@ -752,10 +752,10 @@ std::vector<Future<Result>>
window(Collection input, F func, size_t n) {
struct WindowContext {
WindowContext(Collection&& i, F&& fn)
: i_(0), input_(std::move(i)), promises_(input_.size()),
: input_(std::move(i)), promises_(input_.size()),
func_(std::move(fn))
{}
std::atomic<size_t> i_;
std::atomic<size_t> i_ {0};
Collection input_;
std::vector<Promise<Result>> promises_;
F func_;
......@@ -872,10 +872,10 @@ template <class E>
Future<T> Future<T>::within(Duration dur, E e, Timekeeper* tk) {
struct Context {
Context(E ex) : exception(std::move(ex)), promise(), token(false) {}
Context(E ex) : exception(std::move(ex)), promise() {}
E exception;
Promise<T> promise;
std::atomic<bool> token;
std::atomic<bool> token {false};
};
auto ctx = std::make_shared<Context>(std::move(e));
......
......@@ -414,7 +414,7 @@ struct CollectVariadicContext {
}
Promise<std::tuple<Ts...>> p;
std::tuple<Ts...> results;
std::atomic<bool> threw;
std::atomic<bool> threw {false};
typedef Future<std::tuple<Ts...>> type;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment