git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: Re: [PATCH] Use explicit pointers for execl...() sentinels.
Date: Sun, 12 Mar 2006 22:31:21 -0500	[thread overview]
Message-ID: <20060313033121.GA14601@coredump.intra.peff.net> (raw)
In-Reply-To: <20060312200812.3fb04638.tihirvon@gmail.com>

On Sun, Mar 12, 2006 at 08:08:12PM +0200, Timo Hirvonen wrote:

> NULL pointer does not point to any data, it just says it's 'empty'.  So
> it doesn't need to be same type pointer as specified in the function
> prototype.  Pointers are just addresses, it doesn't matter from to code
> generation point of view whether it is (char *)0 or (void *)0.

Sorry, but I think you're wrong according to the C standard. Pointers of 
different types do NOT have to share the same representation (e.g.,
there have been some platforms where char* and int* were different
sizes). A void pointer must be capable of representing any type of
pointer (for example, holding the largest possible type). However, if
sizeof(void *) == 8 and sizeof(char *) == 4, you have a problem with
variadic functions which are expecting to pull 4 byte off the stack. 

In a non-variadic function, the compiler would do the right implicit
casting. In a variadic function, it can't. 

The real question is, does git want to care about portability to such
platforms.

If you remain unconvinced, I can try to find chapter and verse of the
standard.

> sizeof(unsigned long) is sizeof(void *) in real world.

Are you saying that because it encompasses all of the platforms you've
worked on, or do you have some evidence that it is largely the case? It
certainly isn't guaranteed by the C standard.

> > Because, according to the C and POSIX specs, they're not wrong.
> They didn't think of 64-bit architectures back then, I suppose.

No, they did think of those issues; they intentionally left such sizing
up to the implementation to allow C to grow with the hardware. Mostly
you don't have to care, but as I said, typing with variadic functions is
a pain.

-Peff

  reply	other threads:[~2006-03-13  3:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-11 19:29 [PATCH] Trivial warning fix for imap-send.c Art Haas
2006-03-12 10:44 ` Mark Wooding
2006-03-12 11:27   ` Junio C Hamano
2006-03-12 13:59     ` [PATCH] Use explicit pointers for execl...() sentinels Mark Wooding
2006-03-12 15:13       ` Timo Hirvonen
2006-03-12 17:32         ` Mark Wooding
2006-03-12 18:08           ` Timo Hirvonen
2006-03-13  3:31             ` Jeff King [this message]
2006-03-13  4:12               ` Horst von Brand
2006-03-14  0:42                 ` [OT] " Jeff King
2006-03-12 16:57   ` [PATCH] Trivial warning fix for imap-send.c Linus Torvalds
2006-03-12 18:01     ` Mark Wooding
2006-03-12 19:20       ` A Large Angry SCM
2006-03-13  2:59         ` H. Peter Anvin
2006-03-13  4:36           ` A Large Angry SCM
2006-03-13  5:22             ` Linus Torvalds
2006-03-13  6:37               ` H. Peter Anvin
2006-03-13  6:46                 ` Linus Torvalds
2006-03-13 16:37                 ` Olivier Galibert
2006-03-13  3:38         ` Jeff King
2006-03-13  4:14           ` Horst von Brand
2006-03-13 16:26             ` Linus Torvalds
2006-03-13  6:41           ` H. Peter Anvin
2006-03-12 21:51       ` Horst von Brand
2006-03-12 23:02       ` Linus Torvalds

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=20060313033121.GA14601@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).