Commit d6a27b28 authored by Eric Niebler's avatar Eric Niebler Committed by Facebook Github Bot

Value-initialize the Data union member of folly::Function

Summary: The Data field was not getting value-initialized, leading compilers to complain when value-initializing const folly::Function objects.

Reviewed By: yfeldblum, ot

Differential Revision: D6241712

fbshipit-source-id: 99ce7f6016f6e7d16b1cff7aa51b7bef53ec592d
parent ad3fe1dd
......@@ -529,7 +529,7 @@ class Function final : private detail::function::FunctionTraits<FunctionType> {
// invoking undefined behavior. Const-correctness is only violated when
// `FunctionType` is a const function type (e.g., `int() const`) and `*this`
// is the result of calling `constCastFunction`.
mutable Data data_;
mutable Data data_{};
Call call_{&Traits::uninitCall};
Exec exec_{&detail::function::uninitNoop};
......
......@@ -1095,3 +1095,7 @@ TEST(Function, CtorWithCopy) {
EXPECT_TRUE(noexcept(Function<void()>(lx)));
EXPECT_FALSE(noexcept(Function<void()>(ly)));
}
TEST(Function, Bug_T23346238) {
const Function<void()> nullfun;
}
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