This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch for pedantic format warnings
On Thu, Jul 20, 2000 at 01:54:59PM -0600, Jeffrey A Law wrote:
>
> In message <Pine.SOL.4.21.0007192212390.20964-100000@orange.csi.cam.ac.uk>you
> write:
> > This patch fixes the pedantic warnings generated by my patch
> >
> > http://gcc.gnu.org/ml/gcc-patches/2000-07/msg00704.html
> >
> > and shown up by a bootstrap on i686-pc-linux-gnu.
> >
> > Pointers (other than char * or void *) are cast to PTR for formatting
> > with %p or HOST_PTR_PRINTF.
> Is that really necessary? I'm not a language lawyer, but it seems kind of
> odd to require conversion of a pointer to char * or void * just for the
> *printf* routines.
The standard requires that *printf %p format take a void * (and another place
requires that void * and char * have the same size, alignment, and bit
representation). This becomes important on systems that have multiple formats
of pointers. Just because other parts of GCC might have trouble on such a
machine, we should still make an effort to be type correct. FYI, a group at
Data General did manage to port GCC 10 years ago to a host machine that had
different types of pointers (the Data General MV/Eclipse computer that I wrote
a C front end for before going over to GCC), and it was a real struggle.
>
> > (Why do some places use HOST_PTR_PRINTF, and others %p explicitly?)
> Most likely a bug, especially since not all systems support %p.
Pre-ISO C libraries don't support %p. I would imagine it is a bug.
--
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work: meissner@redhat.com phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org fax: +1 978-692-4482