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
// 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};
EXPECT_TRUE(noexcept(Function<void()>(lx)));
EXPECT_FALSE(noexcept(Function<void()>(ly)));
}
+
+TEST(Function, Bug_T23346238) {
+ const Function<void()> nullfun;
+}