[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.60.0708030024490.6774@poirot.grange>
Date: Fri, 3 Aug 2007 00:36:40 +0200 (CEST)
From: Guennadi Liakhovetski <g.liakhovetski@....de>
To: Robert Hancock <hancockr@...w.ca>,
Stefan Richter <stefanr@...6.in-berlin.de>
cc: Andi Kleen <andi@...stfloor.org>, linux-kernel@...r.kernel.org
Subject: Re: gcc fixed size char array initialization bug - known?
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'. It
is EQUIVALENT to {'s', 't', 'r', 'i', 'n', 'g', '\0'}. And it contains
SEVEN characters. Please, re-read your K&R. Specifically, the Section
"Initialization" in the "Function and Program Structure" chapter (section
4.9 in my copy), the paragraph about initialization with a string, which I
quoted in an earlier email.
And, Stefan, there is a perfect way to specify a "0123" without the '\0' -
{'0', '1', '2', '3'}.
Thanks
Guennadi
---
Guennadi Liakhovetski
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists