Permalink
Browse files

value_ might be uninitialized

Summary: Compilation is failing in 'opt' build

Test Plan: compile

Reviewed By: andrewjcg@fb.com

FB internal diff: D707869
  • Loading branch information...
1 parent 5fabcaa commit 3cc8d95abbc0cf5369b2de6afa40bd72afaa3ffa Rajat Goel committed with jdelong Feb 13, 2013
Showing with 13 additions and 0 deletions.
  1. +13 −0 folly/Optional.h
View
@@ -69,6 +69,17 @@ typedef int detail::NoneHelper::*None;
const None none = nullptr;
+/**
+ * gcc-4.7 warns about use of uninitialized memory around the use of storage_
+ * even though this is explicitly initialized at each point.
+ */
+#ifdef __GNUC__
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wuninitialized"
+# pragma GCC diagnostic ignored "-Wpragmas"
+# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif // __GNUC__
+
template<class Value>
class Optional : boost::totally_ordered<Optional<Value>,
boost::totally_ordered<Optional<Value>, Value>> {
@@ -234,6 +245,8 @@ class Optional : boost::totally_ordered<Optional<Value>,
bool hasValue_;
};
+#pragma GCC diagnostic pop
+
template<class T>
const T* get_pointer(const Optional<T>& opt) {
return opt ? &opt.value() : nullptr;

0 comments on commit 3cc8d95

Please sign in to comment.