Problem found by 'make check' failure on bleeding-edge coreutils on an MPX-enabled CPU (Intel Core i3-7100U) running GCC (Ubuntu 6.2.0-5ubuntu12), configured via "./configure --enable-gcc-warnings CFLAGS='-mmpx -fcheck-pointer-bounds -g3 -O2' LDFLAGS='-static-libmpx -static-libmpxwrappers'". * lib/obstack.h (__FLEXIBLE_ARRAY_MEMBER): New macro, copied from fts_.h. (struct _obstack_chunk.contents): Use it. --- ChangeLog | 12 ++++++++++++ lib/obstack.h | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog index 93be4e9..ec946ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2016-11-14 Paul Eggert <eggert@union> + + obstack: port to gcc -fcheck-pointer-bounds + Problem found by 'make check' failure on bleeding-edge coreutils + on an MPX-enabled CPU (Intel Core i3-7100U) running GCC (Ubuntu + 6.2.0-5ubuntu12), configured via "./configure + --enable-gcc-warnings CFLAGS='-mmpx -fcheck-pointer-bounds -g3 + -O2' LDFLAGS='-static-libmpx -static-libmpxwrappers'". + * lib/obstack.h (__FLEXIBLE_ARRAY_MEMBER): + New macro, copied from fts_.h. + (struct _obstack_chunk.contents): Use it. + 2016-11-14 Eric Blake <ebl...@redhat.com> strerror_r-posix: Another fix, for HAVE_DECL_STRERROR_R on mingw. diff --git a/lib/obstack.h b/lib/obstack.h index e81c907..789bc83 100644 --- a/lib/obstack.h +++ b/lib/obstack.h @@ -111,6 +111,12 @@ #include <stddef.h> /* For size_t and ptrdiff_t. */ #include <string.h> /* For __GNU_LIBRARY__, and memcpy. */ +#if __STDC_VERSION__ < 199901L +# define __FLEXIBLE_ARRAY_MEMBER 1 +#else +# define __FLEXIBLE_ARRAY_MEMBER +#endif + #if _OBSTACK_INTERFACE_VERSION == 1 /* For binary compatibility with obstack version 1, which used "int" and "long" for these two types. */ @@ -162,7 +168,7 @@ struct _obstack_chunk /* Lives at front of each chunk. */ { char *limit; /* 1 past end of this chunk */ struct _obstack_chunk *prev; /* address of prior chunk or NULL */ - char contents[4]; /* objects begin here */ + char contents[__FLEXIBLE_ARRAY_MEMBER]; /* objects begin here */ }; struct obstack /* control current object in current chunk */ -- 2.9.3