[gjs: 9/10] wrapperutils: Avoid template policy warning



commit 643bd1642bc8a6a81df9989d75ce606c56010a21
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue Feb 5 23:22:19 2019 -0800

    wrapperutils: Avoid template policy warning
    
    In cases where the template function pointer parameter type_struct is
    not null in a particular instantiation, GCC will warn about the code
    here that the pointer can never be null. We want to avoid that warning
    because the whole point is that the pointer is always or never null in a
    particular instantiation.

 gi/wrapperutils.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/gi/wrapperutils.cpp b/gi/wrapperutils.cpp
index caa441e9..09ae427b 100644
--- a/gi/wrapperutils.cpp
+++ b/gi/wrapperutils.cpp
@@ -143,7 +143,9 @@ bool gjs_define_static_methods(JSContext* cx, JS::HandleObject constructor,
         }
     }
 
-    if (!InfoMethodsPolicy<TAG>::type_struct)
+    // Casting to void* avoids warning that the function pointer will never be
+    // null in template instantiations where it is not null
+    if (!reinterpret_cast<void*>(InfoMethodsPolicy<TAG>::type_struct))
         return true;
 
     // Also define class/interface methods if there is a gtype struct


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]