On Fri, Aug 03, 2007 at 12:36:40AM +0200, Guennadi Liakhovetski wrote:
> On Thu, 2 Aug 2007, Robert Hancock wrote:
>
> > Because 5 characters will not fit in a 4 character array, even without the
> > null terminator.
>
> On Fri, 3 Aug 2007, Stefan Richter wrote:
>
> > How should gcc know whether you actually wanted that char foo[len] to
> > contain a \0 as last element?
>
> Robert, Stefan, I am sorry, I think, you are VERY wrong here. There is no
> "even" and no guessing. The "string" DOES include a terminating '\0'.
Read the fucking standard. In particular, notice that meaning of
string literals outside of initializer is *defined* via that in
initializers. IOW, string literals contain _nothing_ - not '\0', not
anything else. The entire reason why use of string literal ends up
with anon array containing \0 is exactly there - it's "how do we
determine the actual length of array of character with unknown length
initialized by string literal". _That_ is where \0 comes from.
And yes, all quotes you've given are correct. You are blatantly ignoring
the context even when you are including all relevant parts into the quoted
text. This stuff hadn't changed since K&R.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]