This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

libio/gen-params and linuxlibc1



While doing some testing with the old Linux C library I ran into an
interesting interaction bug in libio.

_G_config.h has at the very end

#undef NULL
#define __need_NULL
#include <stddef.h>

If stddef.h has already defined NULL, it will not do so again.  We are
therefore left with no definition of NULL.  This causes one category
of horrible breakages.  Worse, libc5's stdlib.h has

/* Don't ask me why. H.J. */
#ifndef NULL
#define NULL ((void *)0)
#endif

so any C++ source that includes _G_config.h and then stdlib.h will get
a bogus definition of NULL, leading to another category of horrible
breakages.

I patched gen-params as follows:

===================================================================
Index: gen-params
--- gen-params	1999/03/23 23:58:21	1.9
+++ gen-params	1999/09/06 15:37:58
@@ -728,10 +728,13 @@ fi
 # echo "#define ${macro_prefix}NO_TEMPLATES"
 
 # Override bogus definitions of NULL in system headers.
+# stddef.h might not do anything if it has been included already.
 cat <<EOF
-#undef NULL
 #define __need_NULL
 #include <stddef.h>
+#ifndef NULL
+#define NULL 0
+#endif
 EOF
 
 rm -f dummy.C dummy.o dummy.c dummy.out TMP core a.out

There might be a better fix, though.

This does not show up with libc6 because the system _G_config.h, which
does not undef NULL, is used in that case.

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]