]> git.ipfire.org Git - thirdparty/glibc.git/commit
Silence -O3 -Wall warning in malloc/hooks.c with GCC 7 [BZ #22052]
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 15 Oct 2017 15:16:26 +0000 (08:16 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 15 Oct 2017 15:16:37 +0000 (08:16 -0700)
commit8e57c9432a2b68c8a1e7f4df28f0e8c7acc04753
tree6dd8b1f6f37eba37693ca86d946db379394619a5
parenta4777c46af89649f2282c1703e8117ccd058d719
Silence -O3 -Wall warning in malloc/hooks.c with GCC 7 [BZ #22052]

realloc_check has

  unsigned char *magic_p;
...
  __libc_lock_lock (main_arena.mutex);
  const mchunkptr oldp = mem2chunk_check (oldmem, &magic_p);
  __libc_lock_unlock (main_arena.mutex);
  if (!oldp)
    malloc_printerr ("realloc(): invalid pointer");
...
  if (newmem == NULL)
    *magic_p ^= 0xFF;

with

static void malloc_printerr(const char *str) __attribute__ ((noreturn));

GCC 7 -O3 warns

hooks.c: In function ‘realloc_check’:
hooks.c:352:14: error: ‘magic_p’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     *magic_p ^= 0xFF;

due to the GCC bug:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82090

This patch silences GCC 7 by using DIAG_IGNORE_NEEDS_COMMENT.

[BZ #22052]
* malloc/hooks.c (realloc_check): Use DIAG_IGNORE_NEEDS_COMMENT
to silence -O3 -Wall warning with GCC 7.
ChangeLog
malloc/hooks.c