Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: facebook/folly
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 126e2bbb072a90e0de2f4e36437c1304121bb698
Choose a base ref
...
head repository: facebook/folly
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 98c8bfbc3ecfb022dc2d077031d4c3eee29d4e0b
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 19, 2024

  1. fix violations of warning uninitialized in UtilityTest

    Reviewed By: Gownta
    
    Differential Revision: D65737540
    
    fbshipit-source-id: ccee1153c98a60c268fe6543bcdac10715cde3da
    yfeldblum authored and facebook-github-bot committed Nov 19, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    sirreal Jon Surrell
    Copy the full SHA
    36f0a38 View commit details

Commits on Nov 20, 2024

  1. 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
    yfeldblum authored and facebook-github-bot committed Nov 20, 2024
    Copy the full SHA
    98c8bfb View commit details
Showing with 11 additions and 2 deletions.
  1. +9 −0 folly/Optional.h
  2. +2 −2 folly/test/UtilityTest.cpp
9 changes: 9 additions & 0 deletions folly/Optional.h
Original file line number Diff line number Diff line change
@@ -251,15 +251,21 @@ class Optional {

void assign(Value&& newValue) {
if (hasValue()) {
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wmaybe-uninitialized")
storage_.value = std::move(newValue);
FOLLY_POP_WARNING
} else {
construct(std::move(newValue));
}
}

void assign(const Value& newValue) {
if (hasValue()) {
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wmaybe-uninitialized")
storage_.value = newValue;
FOLLY_POP_WARNING
} else {
construct(newValue);
}
@@ -476,7 +482,10 @@ class Optional {
void clear() {
if (hasValue) {
hasValue = false;
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wmaybe-uninitialized")
value.~Value();
FOLLY_POP_WARNING
}
}
};
4 changes: 2 additions & 2 deletions folly/test/UtilityTest.cpp
Original file line number Diff line number Diff line change
@@ -263,7 +263,7 @@ template class TestCopyMove<true, true>;

TEST_F(UtilityTest, MoveOnly) {
class FooBar : folly::MoveOnly {
int a;
[[maybe_unused]] int a = 0;
};

static_assert(
@@ -284,7 +284,7 @@ TEST_F(UtilityTest, MoveOnly) {

TEST_F(UtilityTest, NonCopyableNonMovable) {
class FooBar : folly::NonCopyableNonMovable {
int a;
[[maybe_unused]] int a = 0;
};

static_assert(