bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: definition of NULL


From: Bruno Haible
Subject: Re: definition of NULL
Date: Tue, 11 Aug 2009 21:07:24 +0200
User-agent: KMail/1.9.9

Hi Eric,

You wrote on 2009-06-26:
> +/* Check that NULL can be passed through varargs as a pointer type,
> +   per POSIX 2008.  */
> +verify (sizeof NULL == sizeof (void *));

Citing <https://savannah.gnu.org/support/?106973>:

  on NetBSD 5.0 amd64, test-locale.c fails to build
  because the call to verify says "sizeof NULL".   On NetBSD, NULL is "(void
  *)0", and gcc fails to parse "sizeof (void*)0".  Changing this to "sizeof
  (NULL)" makes the tests compile

Indeed, "sizeof (void*)0" parses as sizeof of the type 'void *', followed by a
stray 0 token => parse error.

I'm applying this fix:


2009-08-11  Bruno Haible  <address@hidden>

        Avoid compilation error on NetBSD 5.0.
        * tests/test-locale.c: Write sizeof (NULL) instead of sizeof NULL.
        * tests/test-stdio.c: Likewise.
        * tests/test-stdlib.c: Likewise.
        * tests/test-string.c: Likewise.
        * tests/test-unistd.c: Likewise.
        Reported by Greg Troxel <address@hidden>
        at <https://savannah.gnu.org/support/?106973>.

--- tests/test-locale.c.orig    2009-08-11 21:06:18.000000000 +0200
+++ tests/test-locale.c 2009-08-11 21:04:30.000000000 +0200
@@ -35,7 +35,7 @@
 
 /* Check that NULL can be passed through varargs as a pointer type,
    per POSIX 2008.  */
-verify (sizeof NULL == sizeof (void *));
+verify (sizeof (NULL) == sizeof (void *));
 
 int
 main ()
--- tests/test-stdio.c.orig     2009-08-11 21:06:18.000000000 +0200
+++ tests/test-stdio.c  2009-08-11 21:04:30.000000000 +0200
@@ -27,7 +27,7 @@
 
 /* Check that NULL can be passed through varargs as a pointer type,
    per POSIX 2008.  */
-verify (sizeof NULL == sizeof (void *));
+verify (sizeof (NULL) == sizeof (void *));
 
 int
 main ()
--- tests/test-stdlib.c.orig    2009-08-11 21:06:18.000000000 +0200
+++ tests/test-stdlib.c 2009-08-11 21:04:30.000000000 +0200
@@ -26,7 +26,7 @@
 
 /* Check that NULL can be passed through varargs as a pointer type,
    per POSIX 2008.  */
-verify (sizeof NULL == sizeof (void *));
+verify (sizeof (NULL) == sizeof (void *));
 
 int
 main ()
--- tests/test-string.c.orig    2009-08-11 21:06:18.000000000 +0200
+++ tests/test-string.c 2009-08-11 21:04:30.000000000 +0200
@@ -24,7 +24,7 @@
 
 /* Check that NULL can be passed through varargs as a pointer type,
    per POSIX 2008.  */
-verify (sizeof NULL == sizeof (void *));
+verify (sizeof (NULL) == sizeof (void *));
 
 int
 main ()
--- tests/test-unistd.c.orig    2009-08-11 21:06:18.000000000 +0200
+++ tests/test-unistd.c 2009-08-11 21:04:31.000000000 +0200
@@ -24,7 +24,7 @@
 
 /* Check that NULL can be passed through varargs as a pointer type,
    per POSIX 2008.  */
-verify (sizeof NULL == sizeof (void *));
+verify (sizeof (NULL) == sizeof (void *));
 
 /* Check that the various SEEK_* macros are defined.  */
 int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET };




reply via email to

[Prev in Thread] Current Thread [Next in Thread]