You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ make
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local
-- The C compiler identification is GNU 16.0.1
...
[ 22%] Building C object CMakeFiles/qjs.dir/quickjs.c.o
/src/quickjs.c: In function‘js_default_module_normalize_name’:
/src/quickjs.c:29087:7: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
29087 | p = strrchr(base_name, '/');| ^
In function‘js_bigint_sign’,
inlined from ‘js_bigint_get_si_sat’ at /src/quickjs.c:12114:13,
inlined from ‘js_binary_logic_slow’ at /src/quickjs.c:15091:25:
/src/quickjs.c:12106:18: error: ‘buf2’ may be used uninitialized [-Werror=maybe-uninitialized]
12106 |return a->tab[a->len - 1] >> (JS_LIMB_BITS - 1);|~~~~~~^~~~~~~~~~~~
/src/quickjs.c: In function‘js_binary_logic_slow’:
/src/quickjs.c:15071:27: note: ‘buf2’ declared here
15071 | JSBigIntBuf buf1, buf2;| ^~~~
In function‘js_bigint_sign’,
inlined from ‘js_bigint_get_si_sat’ at /src/quickjs.c:12114:13,
inlined from ‘js_binary_logic_slow’ at /src/quickjs.c:15091:25:
/src/quickjs.c:12106:18: error: ‘buf2’ may be used uninitialized [-Werror=maybe-uninitialized]
12106 |return a->tab[a->len - 1] >> (JS_LIMB_BITS - 1);|~~~~~~^~~~~~~~~~~~
/src/quickjs.c: In function‘js_binary_logic_slow’:
/src/quickjs.c:15071:27: note: ‘buf2’ declared here
15071 | JSBigIntBuf buf1, buf2;| ^~~~
The first warning is because you're compiling quickjs as a C23 project (which it isn't - yet):
/src/quickjs.c:29087:7: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
29087 | p = strrchr(base_name, '/');
strrchr's pre-C23 prototype is char *strrchr(const char *, int) but the error message implies gcc thinks it's the C23 prototype where the return type is the type of the first argument (relevant search engine keywords: qchar c23)
The others are false positives. Not sure why gcc gets confused.
I guess this could be intentional on gcc's part, standard doesn't mandate warnings. -Werror makes the compiler behave stricter than the standard prescribes. quickjs has the same discarded-qualifiers warning and without -Werror in its Makefile it compiles fine.
Not sure maybe-uninitialized warnings - quickjs doesn't have that one.
Activity
bnoordhuis commentedon Feb 9, 2026
The first warning is because you're compiling quickjs as a C23 project (which it isn't - yet):
strrchr's pre-C23 prototype is
char *strrchr(const char *, int)but the error message implies gcc thinks it's the C23 prototype where the return type is the type of the first argument (relevant search engine keywords:qchar c23)The others are false positives. Not sure why gcc gets confused.
ivankra commentedon Feb 10, 2026
Oh yes, looks like gcc 16 is switching to C23 as the default - https://www.phoronix.com/news/GCC-Prepares-std-gnu23-Default
cmake passes -std=gnu11 flag to gcc, but it doesn't affect that warning, which becomes an error due to -Werror:
I guess this could be intentional on gcc's part, standard doesn't mandate warnings. -Werror makes the compiler behave stricter than the standard prescribes. quickjs has the same discarded-qualifiers warning and without -Werror in its Makefile it compiles fine.
Not sure maybe-uninitialized warnings - quickjs doesn't have that one.
bnoordhuis commentedon Feb 10, 2026
We shouldn't be setting -Werror except in CI or developer builds. I'll file a new issue for that.
The strrchr warning is simple to fix. I'll open a pull request for that.
Fix C23 -Wdiscarded-qualifiers compiler warning
Fix C23 -Wdiscarded-qualifiers compiler warning (#1338)
Fix C23 -Wdiscarded-qualifiers compiler warning (quickjs-ng#1338)