Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix violations of warning maybe-uninitialized under GCC in Optional
Summary: Addresses the following warning violation reports. ``` In member function ‘void std::__shared_count<_Lp>::_M_swap(std::__shared_count<_Lp>&) [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’, inlined from ‘void std::__shared_ptr<_Tp, _Lp>::swap(std::__shared_ptr<_Tp, _Lp>&) [with _Tp = int; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at /opt/rh/gcc-toolset-13/root/usr/include/c++/13/bits/shared_ptr_base.h:1687:21, inlined from ‘std::__shared_ptr<_Tp, _Lp>& std::__shared_ptr<_Tp, _Lp>::operator=(std::__shared_ptr<_Tp, _Lp>&&) [with _Tp = int; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at /opt/rh/gcc-toolset-13/root/usr/include/c++/13/bits/shared_ptr_base.h:1620:35, inlined from ‘std::shared_ptr<_Tp>& std::shared_ptr<_Tp>::operator=(std::shared_ptr<_Tp>&&) [with _Tp = int]’ at /opt/rh/gcc-toolset-13/root/usr/include/c++/13/bits/shared_ptr.h:440:36, inlined from ‘void folly::Optional<Value>::assign(Value&&) [with Value = std::shared_ptr<int>]’ at /data/users/yfeldblum/scratch/dataZusersZyfeldblumZfbsource-s1/fbcode_builder_getdeps/shipit/folly/folly/Optional.h:254:22, inlined from ‘folly::Optional<Value>& folly::Optional<Value>::operator=(Arg&&) [with Arg = std::shared_ptr<int>; Value = std::shared_ptr<int>]’ at folly/Optional.h:276:11, inlined from ‘virtual void folly::Optional_Shared_Test::TestBody()’ at folly/test/OptionalTest.cpp:332:22: /opt/rh/gcc-toolset-13/root/usr/include/c++/13/bits/shared_ptr_base.h:1099:32: warning: ‘((std::__shared_count<__gnu_cxx::_S_atomic>*)((char*)&opt + offsetof(folly::Optional<std::shared_ptr<int> >,folly::Optional<std::shared_ptr<int> >::storage_.folly::Optional<std::shared_ptr<int> >::StorageNonTriviallyDestructible::<unnamed>)))[1].std::__shared_count<>::_M_pi’ may be used uninitialized [-Wmaybe-uninitialized] 1099 | _Sp_counted_base<_Lp>* __tmp = __r._M_pi; | ^~~~~ folly/test/OptionalTest.cpp: In member function ‘virtual void folly::Optional_Shared_Test::TestBody()’: folly/test/OptionalTest.cpp:315:29: note: ‘opt’ declared here 315 | Optional<shared_ptr<int>> opt; | ^~~ ``` ``` In member function ‘std::size_t folly::Function<FunctionType>::exec(Op, Data*, Data*) const [with FunctionType = void()]’, inlined from ‘folly::Function<FunctionType>::~Function() [with FunctionType = void()]’ at folly/Function.h:789:21, inlined from ‘void folly::Optional<Value>::StorageNonTriviallyDestructible::clear() [with Value = folly::Function<void()>]’ at folly/Optional.h:479:21, inlined from ‘folly::Optional<Value>::StorageNonTriviallyDestructible::~StorageNonTriviallyDestructible() [with Value = folly::Function<void()>]’ at folly/Optional.h:474:47, inlined from ‘folly::Optional<folly::Function<void()> >::~Optional()’ at folly/Optional.h:111:7, inlined from ‘folly::Optional<T> folly::UnboundedQueue<T, SingleProducer, SingleConsumer, MayBlock, LgSegmentSize, LgAlign, Atom>::tryDequeueUntilSC(Segment*, const std::chrono::time_point<_Clock, _Duration>&) [with Clock = std::chrono::_V2::steady_clock; Duration = std::chrono::duration<longint, std::ratio<1, 1000000000> >; T = folly::Function<void()>; bool SingleProducer = false; bool SingleConsumer = true; bool MayBlock = true; long unsigned int LgSegmentSize = 8; long unsigned int LgAlign = 7; Atom = std::atomic]’ at folly/concurrency/UnboundedQueue.h:468:3, inlined from ‘folly::Optional<T> folly::UnboundedQueue<T, SingleProducer, SingleConsumer, MayBlock, LgSegmentSize, LgAlign, Atom>::tryDequeueUntil(const std::chrono::time_point<_Clock, _Duration>&) [with Clock = std::chrono::_V2::steady_clock; Duration = std::chrono::duration<long int, std::ratio<1, 1000000000> >; T = folly::Function<void()>; bool SingleProducer = false; bool SingleConsumer = true; bool MayBlock = true; long unsigned int LgSegmentSize = 8; long unsigned int LgAlign = 7; Atom = std::atomic]’ at folly/concurrency/UnboundedQueue.h:439:43, inlined from ‘folly::Optional<T> folly::UnboundedQueue<T, SingleProducer, SingleConsumer, MayBlock, LgSegmentSize, LgAlign, Atom>::try_dequeue() [with T = folly::Function<void()>; bool SingleProducer = false; bool SingleConsumer = true; bool MayBlock = true; long unsigned int LgSegmentSize= 8; long unsigned int LgAlign = 7; Atom = std::atomic]’ at folly/concurrency/UnboundedQueue.h:299:72, inlined from ‘bool folly::UnboundedQueue<T, SingleProducer, SingleConsumer, MayBlock, LgSegmentSize, LgAlign, Atom>::try_dequeue(T&) [with T = folly::Function<void()>; bool SingleProducer = false; bool SingleConsumer = true; bool MayBlock = true; long unsigned int LgSegmentSize = 8; long unsigned int LgAlign = 7; Atom = std::atomic]’ at folly/concurrency/UnboundedQueue.h:290:10, inlined from ‘size_t folly::TimedDrivableExecutor::run()’ at folly/executors/TimedDrivableExecutor.cpp:58:41: folly/Function.h:642:10: warning: ‘ret.folly::Optional<folly::Function<void()> >::storage_.folly::Optional<folly::Function<void()> >::StorageNonTriviallyDestructible::<unnamed>.folly::Optional<folly::Function<void()> >::StorageNonTriviallyDestructible::._anon_158::value.folly::Function<void()> ::exec_’ may be used uninitialized [-Wmaybe-uninitialized] 642 | if (!exec_) { | ^~~~~ folly/concurrency/UnboundedQueue.h: In member function ‘size_t folly::TimedDrivableExecutor::run()’: folly/concurrency/UnboundedQueue.h:463:24: note: ‘ret’ declared here 463 | folly::Optional<T> ret = e.takeItem(); | ^~~ ``` Reviewed By: Gownta Differential Revision: D65738230 fbshipit-source-id: 714753de7ff8be89b2fb3446b1104c89be0f6763
- Loading branch information