value_ might be uninitialized
authorRajat Goel <rajatgoel2010@fb.com>
Wed, 13 Feb 2013 20:38:02 +0000 (12:38 -0800)
committerJordan DeLong <jdelong@fb.com>
Tue, 19 Mar 2013 00:07:24 +0000 (17:07 -0700)
Summary: Compilation is failing in 'opt' build

Test Plan: compile

Reviewed By: andrewjcg@fb.com

FB internal diff: D707869

folly/Optional.h

index 8abbfbc073862fa811892ada9e71170e0347c3ba..5b574f5b509dd557189a9aa3eb5f2836b9d4d37a 100644 (file)
@@ -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;