Skip to content

Commit

Permalink
src/get.c: Disable false GCC warning
Browse files Browse the repository at this point in the history
GCC 14.2.1 doesn't seem to be able to analyze this stack frame code
correctly.  When compiling augeas with --enable-compile-warnings=error
that causes the build to fail with the errors below.  Disable the
error around this code.

In file included from /usr/include/string.h:548,
                 from ../gnulib/lib/string.h:41,
                 from internal.h:31,
                 from get.c:30:
In function ‘memset’,
    inlined from ‘push_frame’ at get.c:1095:5:
/usr/include/bits/string_fortified.h:59:10: error: ‘__builtin_memset’ offset [0, 31] is out of the bounds [0, 0] [-Werror=array-bounds=]
   59 |   return __builtin___memset_chk (__dest, __ch, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   60 |                                  __glibc_objsize0 (__dest));
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~

If you disable -Warray-bounds only then you get this instead:

In file included from /usr/include/string.h:548,
                 from ../gnulib/lib/string.h:41,
                 from internal.h:31,
                 from get.c:30:
In function ‘memset’,
    inlined from ‘push_frame’ at get.c:1100:5:
/usr/include/bits/string_fortified.h:59:10: error: ‘__builtin_memset’ writing 32 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
   59 |   return __builtin___memset_chk (__dest, __ch, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   60 |                                  __glibc_objsize0 (__dest));
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘push_frame’:
cc1: note: destination object is likely at address zero

Signed-off-by: Richard W.M. Jones <[email protected]>
  • Loading branch information
rwmjones committed Aug 6, 2024
1 parent a685bc1 commit 4db6218
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/get.c
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,14 @@ static struct frame *push_frame(struct rec_state *state, struct lens *lens) {
state->fused += 1;

struct frame *top = top_frame(state);
/* GCC 14.2.1 cannot analyze this correctly, so it breaks with
* -Werror. Until this is fixed in GCC, disable the warning.
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#pragma GCC diagnostic ignored "-Wstringop-overflow"
MEMZERO(top, 1);
#pragma GCC diagnostic pop
top->lens = lens;
return top;
error:
Expand Down

0 comments on commit 4db6218

Please sign in to comment.