From: "M. Warner Losh" <imp@bsdimp.com>
To: qemu-devel@nongnu.org, carenas@sajinet.com.pe
Subject: Re: [Qemu-devel] error compiling hw/sh7750.c
Date: Sun, 11 Nov 2007 10:46:31 -0700 (MST) [thread overview]
Message-ID: <20071111.104631.756906125.imp@bsdimp.com> (raw)
In-Reply-To: <20071111172122.GA9387@tapir>
In message: <20071111172122.GA9387@tapir>
Carlo Marcelo Arenas Belon <carenas@sajinet.com.pe> writes:
: On Sun, Nov 11, 2007 at 10:06:34AM -0600, Carlo Marcelo Arenas Belon wrote:
: > On Sun, Nov 11, 2007 at 09:30:26AM -0500, Ben Taylor wrote:
: > > So the macro turns the last _INTC_ARRAY(NULL) into
: > >
: > > "NULL, sizeof(NULL)/sizeof(*NULL)
: >
: > in my 64bit linux using gcc-4.1.2 it becomes instead :
: >
: > ((void *)0), sizeof(((void *)0))/sizeof(*((void *)0))
: >
: > what version of gcc (gcc -v) are you using in that Solaris 10 box? (HINT: not
: > all available versions of gcc compile qemu correctly) :
: >
: > http://www.opensolaris.org/os/project/qemu/host/gcc-failures/
:
: That didn't sound as clear as it should, so I booted an OpenSolaris Nevada 70b
: using the sun provided gcc :
:
: $ uname -a
: SunOS dell 5.11 snv_70b i86pc i386 i86pc
: $ gcc -v
: Reading specs from /usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/specs
: Configured with: /builds2/sfwnv-gate/usr/src/cmd/gcc/gcc-3.4.3/configure
: --prefix=/usr/sfw --with-as=/usr/sfw/bin/gas --with-gnu-as
: --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++,f77,objc
: --enable-shared
: Thread model: posix
: gcc version 3.4.3 (csl-sol210-3_4-20050802)
:
: and run a test, the problem is in /usr/include/iso/stdio_iso.h that defined
: NULL as an int and not a pointer as shown by :
:
: fndef NULL
: #if defined(_LP64)
: #define NULL 0L
: #else
: #define NULL 0
: #endif
: #endif
:
: contradicting (at least in spirit) the C99 (ISO/IEC 9899:TCS) standard that
: says :
:
: "A pointer to void shall have the same representation and alignment
: requirements as a pointer to a character type"
NULL isn't a pointer. It is a integral constant, per section
6.3.2.3.3 of C99. So *NULL is undefined. If you want a constant
thats an actual pointer, you need to define one special.
6.3.2.3 Pointers
...
[#3] An integer constant expression with the value 0, or
such an expression cast to type void *, is called a null
pointer constant. If a null pointer constant is assigned
to or compared for equality to a pointer, the constant is
converted to a pointer of that type. Such a pointer, called
a null pointer, is guaranteed to compare unequal to a
pointer to any object or function.
[#4] Conversion of a null pointer to another pointer type
yields a null pointer of that type. Any two null pointers
shall compare equal.
7.17 Common definitions <stddef.h>
...
[#3] The macros are
NULL
which expands to an implementation-defined null pointer
constant; and
..
The root cause is of this whole problem is *NULL, an undefined,
unportable construct. That's what should be fixed, not the definition
of NULL if you want this code to be portable.
Warner
next prev parent reply other threads:[~2007-11-11 17:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-11 14:30 [Qemu-devel] error compiling hw/sh7750.c Ben Taylor
2007-11-11 16:06 ` Carlo Marcelo Arenas Belon
2007-11-11 17:21 ` Carlo Marcelo Arenas Belon
2007-11-11 17:24 ` Paul Brook
2007-11-11 18:03 ` Carlo Marcelo Arenas Belon
2007-11-11 17:46 ` M. Warner Losh [this message]
2007-11-11 17:49 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071111.104631.756906125.imp@bsdimp.com \
--to=imp@bsdimp.com \
--cc=carenas@sajinet.com.pe \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.