From: Paul Eggert Date: Tue, 15 Nov 2016 03:48:28 +0000 (-0800) Subject: obstack: port to gcc -fcheck-pointer-bounds X-Git-Tag: v1.0~6554 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=9f623dc537adede7818aeddd68c53680fdfd2bb8;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 93be4e91c2..ec946ca0b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2016-11-14 Paul Eggert + + 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 strerror_r-posix: Another fix, for HAVE_DECL_STRERROR_R on mingw. diff --git a/lib/obstack.h b/lib/obstack.h index e81c907a68..789bc83620 100644 --- a/lib/obstack.h +++ b/lib/obstack.h @@ -111,6 +111,12 @@ #include /* For size_t and ptrdiff_t. */ #include /* 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 */