internal: ignore array-bounds errors on GCC >= 12

As noted in the comment, GCC 12.0 onwards generates an invalid warning about
array bounds when we cast a stack allocated object to cl_object and use it

    warning: array subscript ‘union cl_lispunion[0]’ is partly outside array
    bounds of ‘struct ecl_stack_frame[1]’ [-Warray-bounds=]

The code is conforming, but apparently GCC IR has generated a dead branch that
accesses the array out of bounds. For time being we disable this warning.

See also:
https://gitlab.com/libeigen/eigen/-/issues/2506
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106274
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523

and generally explroe gcc bugzilla for this kind of false positive.
This commit is contained in:
Daniel Kochmański 2025-05-02 08:24:26 +02:00
parent 2948a57174
commit a44a74a3f4

View file

@ -321,6 +321,21 @@ extern cl_object si_constant_form_value _ECL_ARGS((cl_narg narg, cl_object form,
/* interpreter.d */
#if __GNUC__>=12
/* GCC starting from 12.0 (still present in GCC 14.2.1) issues a warning for
conforming code. The warning is based on a dead code generated by its IR:
warning: array subscript union cl_lispunion[0] is partly outside array
bounds of struct ecl_stack_frame[1] [-Warray-bounds=]
Numerous issues reported in GCC tracker, i.e:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106274
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
-- jd 2025-05-02 */
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
#define ECL_BUILD_STACK_FRAME(env,name,frame) \
struct ecl_stack_frame frame;\
cl_object name = ecl_stack_frame_open(env, (cl_object)&frame, 0);