This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Patch for undefined behaviour in gcc
- To: libc-alpha Mailinglist <libc-alpha at sourceware dot cygnus dot com>
- Subject: Patch for undefined behaviour in gcc
- From: Andreas Jaeger <aj at suse dot de>
- Date: 26 Oct 2000 11:47:29 +0200
- Cc: Neil Booth <NeilB at earthling dot net>
Neil has implemented a new cpp which warns about (see gcc-patches, the
patch is not in yet, I'm just testing it):
o A new diagnostic: the "defined" operator resulting from a macro
expansion in a preprocessor conditional (undefined behaviour according
to the standard).
Here's a patch to get rid of these warnings. Ok, to commit?
Andreas
2000-10-26 Andreas Jaeger <aj@suse.de>
* sysdeps/generic/_G_config.h (_G_HAVE_ST_BLKSIZE): Avoid
undefined behaviour.
* sysdeps/gnu/_G_config.h (_G_HAVE_ST_BLKSIZE): Likewise.
* malloc/malloc.c (HAVE_MREMAP): Likewise.
* sysdeps/i386/i686/memset.S: Likewise.
============================================================
Index: sysdeps/generic/_G_config.h
--- sysdeps/generic/_G_config.h 1999/08/15 15:19:28 1.10
+++ sysdeps/generic/_G_config.h 2000/10/26 09:46:11
@@ -76,7 +76,10 @@
#define _G_IO_IO_FILE_VERSION 0x20001
/* This is defined by <bits/stat.h> if `st_blksize' exists. */
-#define _G_HAVE_ST_BLKSIZE defined (_STATBUF_ST_BLKSIZE)
+#ifdef _STATBUF_ST_BLKSIZE
+# define _G_HAVE_ST_BLKSIZE 1
+#endif
+
#define _G_BUFSIZ 8192
============================================================
Index: sysdeps/gnu/_G_config.h
--- sysdeps/gnu/_G_config.h 2000/09/06 21:32:08 1.1
+++ sysdeps/gnu/_G_config.h 2000/10/26 09:46:11
@@ -80,7 +80,9 @@
#define _G_FSTAT64(fd,buf) __fxstat64 (_STAT_VER, fd, buf)
/* This is defined by <bits/stat.h> if `st_blksize' exists. */
-#define _G_HAVE_ST_BLKSIZE defined (_STATBUF_ST_BLKSIZE)
+#ifdef _STATBUF_ST_BLKSIZE
+# define _G_HAVE_ST_BLKSIZE 1
+#endif
#define _G_BUFSIZ 8192
============================================================
Index: malloc/malloc.c
--- malloc/malloc.c 2000/09/29 03:37:28 1.75
+++ malloc/malloc.c 2000/10/26 09:46:22
@@ -528,7 +528,9 @@
*/
#ifndef HAVE_MREMAP
-#define HAVE_MREMAP defined(__linux__)
+# ifdef __linux__
+# define HAVE_MREMAP 1
+# endif
#endif
/* Define USE_ARENAS to enable support for multiple `arenas'. These
============================================================
Index: sysdeps/i386/i686/memset.S
--- sysdeps/i386/i686/memset.S 2000/06/26 22:15:00 1.4
+++ sysdeps/i386/i686/memset.S 2000/10/26 09:46:22
@@ -25,7 +25,9 @@
#include "bp-asm.h"
/* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */
-#define BZERO_P (defined memset)
+#ifdef memset
+# define BZERO_P 1
+#endif
#define PARMS LINKAGE+4 /* space for 1 saved reg */
#if BZERO_P
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj