[lkml]   [2007]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: gcc fixed size char array initialization bug - known?
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
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-08-03 01:05    [W:0.066 / U:4.236 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site