Bug 1430729 - Ignore an incorrect warning with gcc (-Wuninitialized) r?froydnj draft
authorSylvestre Ledru <sledru@mozilla.com>
Tue, 16 Jan 2018 16:19:33 +0100
changeset 720966 ddf07d6dd425685bc551aebab0aaec75a4b9afa7
parent 720932 95cfb6d0075b4abc0e0bb27dafe77cbac769a7e1
child 746216 12242d2898d872fdb361be8ca44c91d09807ccab
push id95712
push userbmo:sledru@mozilla.com
push dateTue, 16 Jan 2018 16:52:56 +0000
reviewersfroydnj
bugs1430729
milestone59.0a1
Bug 1430729 - Ignore an incorrect warning with gcc (-Wuninitialized) r?froydnj MozReview-Commit-ID: 2VfQ8E5d0gZ
xpcom/base/StaticPtr.h
--- a/xpcom/base/StaticPtr.h
+++ b/xpcom/base/StaticPtr.h
@@ -99,17 +99,25 @@ class MOZ_ONLY_USED_TO_AVOID_STATIC_CONS
 {
 public:
   // In debug builds, check that mRawPtr is initialized for us as we expect
   // by the compiler.  In non-debug builds, don't declare a constructor
   // so that the compiler can see that the constructor is trivial.
 #ifdef DEBUG
   StaticRefPtr()
   {
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wuninitialized"
+  // False positive with gcc. See bug 1430729
+#endif
     MOZ_ASSERT(!mRawPtr);
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
   }
 #endif
 
   StaticRefPtr<T>& operator=(T* aRhs)
   {
     AssignWithAddref(aRhs);
     return *this;
   }