]> Savannah Git Hosting - gnulib.git/commitdiff
obstack: port to gcc -fcheck-pointer-bounds
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Nov 2016 03:48:28 +0000 (19:48 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Nov 2016 03:50:43 +0000 (19:50 -0800)
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
lib/obstack.h

index 93be4e91c243f22fd6772cce550310f2fa90d2be..ec946ca0b286d20648008146712ced254cfdb8c1 100644 (file)
--- 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  <eblake@redhat.com>
 
        strerror_r-posix: Another fix, for HAVE_DECL_STRERROR_R on mingw.
index e81c907a68de24e3742f90c389d47122f3b338ef..789bc83620a1862556849e150d060bd1d6dfe9e9 100644 (file)
 #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 */