Re: [PATCH 1/3] diff --stat: allow custom diffstat output width.

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

 




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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]