git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/3] diff --stat: allow custom diffstat output width.
Date: Thu, 28 Sep 2006 23:17:14 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0609282307220.3952@g5.osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0609282252430.3952@g5.osdl.org>



On Thu, 28 Sep 2006, Linus Torvalds wrote:
> 
> because the only reason strtoul() warns now is that C type-rules don't 
> allow the (obviously safe - but pointers migth have strange 
> representations) conversion of "char **" into "const char **", even though 
> "char *" can be converted into "const char *".

I phrased that badly. 

IF C pointer conversion allowed implicit addition of "const" past the 
top-most level, ANSI C would have just done "strtoul()" as 

	unsigned long strtoul(const char *n, const char **p, int);

ie they could just have added the "const" not just to the first argument, 
and legact programs (without const) would still have worked fine.

But _because_ that's not how C type rules work, we have the current 
situation where the first argument is a "const char *", and the second 
argument _logically_ should be a pointer to such an entity, but because 
that would have caused bogus warnings for any code that just used a 
regular "char **" without any const at all, that wasn't an option.

So that explains why ANSI C has insane imbalances like this. It's easy to 
add a "const" to a _first-level_ pointer to say "we allow both const and 
regular pointers to this thing", but sadly you can't do it for a pointer 
to such a pointer.

			Linus

  parent reply	other threads:[~2006-09-29  6:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-27  2:40 [PATCH 1/3] diff --stat: allow custom diffstat output width Junio C Hamano
2006-09-27  3:11 ` David Rientjes
2006-09-28 20:54 ` Linus Torvalds
2006-09-28 21:27   ` Junio C Hamano
2006-09-28 22:07     ` Linus Torvalds
2006-09-29  1:35       ` Junio C Hamano
2006-09-29  5:26       ` Junio C Hamano
2006-09-29  5:58         ` Linus Torvalds
2006-09-29  6:11           ` Junio C Hamano
2006-09-29  6:17           ` Linus Torvalds [this message]
2006-09-28 22:24   ` Adrian Bunk
2006-09-28 22:26     ` Johannes Schindelin

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=Pine.LNX.4.64.0609282307220.3952@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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).