Closed
Description
Compiling on MacOS with GCC >= 11 will fail with error:
[ 23%] Building C object CMakeFiles/qjs.dir/quickjs.c.o
In file included from /Users/andrew/Git/quickjs-ng/quickjs.c:43:
In function 'js__malloc_usable_size',
inlined from 'js_def_malloc' at /Users/andrew/Git/quickjs-ng/quickjs.c:1706:51:
/Users/andrew/Git/quickjs-ng/cutils.h:488:12: error: 'ptr' may be used uninitialized [-Werror=maybe-uninitialized]
488 | return malloc_size(ptr);
This is because the js__malloc_usable_size
function is defined using malloc_size
on MacOS, which has signature:
size_t malloc_size(const void * __unsafe_indexable ptr);
From GCC >=11, -Wmaybe-uninitialised
has stricter warnings on inputs to a const-qualified parameter, which has caused issues already. You can see a small reprex of this behaviour on godbolt
I believe this is also the cause of the warnings seen by @barracuda156 in this comment/issue
Metadata
Metadata
Assignees
Labels
No labels