quickjs-ng / quickjs

QuickJS, the Next Generation: a mighty JavaScript engine
MIT License
698 stars 66 forks source link

Ignore maybe-uninitialised on MacOS with GCC >= 11 #454

Closed andrjohns closed 4 days ago

andrjohns commented 4 days ago

Closes #453

saghul commented 4 days ago

Does this silence the warning?

diff --git a/cutils.h b/cutils.h
index 26436d4..6d0c994 100644
--- a/cutils.h
+++ b/cutils.h
@@ -484,6 +484,8 @@ uint64_t js__hrtime_ns(void);

 static inline size_t js__malloc_usable_size(const void *ptr)
 {
+    if (!ptr)
+        return 0;
 #if defined(__APPLE__)
     return malloc_size(ptr);
 #elif defined(_WIN32)
andrjohns commented 4 days ago

Unfortunately not. If you want to experiment with other approaches you can also see the warning in action here: https://godbolt.org/z/jq15nWz5d