Jakub Jelinek wrote:
> ISO C99 is very obvious in that the terminating '\0' (resp. L'\0') from
> the string literal is only added if there is room in the array or if the
> array has unknown size.
I would say C99 is /explicit/ in this regard.
It doesn't seem like an overly /obvious/ language
On Fri, 3 Aug 2007 00:09:15 +0100, "Al Viro" <[EMAIL PROTECTED]>
said:
> On Fri, Aug 03, 2007 at 12:51:16AM +0200, Guennadi Liakhovetski wrote:
> > On Fri, 3 Aug 2007, Stefan Richter wrote:
> >
> > > Guennadi Liakhovetski wrote:
> > > > with
> > > >
> > > > char c[4] = "012345";
> > > >
On Aug 3 2007 01:30, Guennadi Liakhovetski wrote:
>On Fri, 3 Aug 2007, Al Viro wrote:
>
>> It doesn't change the fact that use of c[4] or strlen(c) or strcpy(..., c)
>> means nasal demon country for you.
>
>Haha, funny. You, certainly, may think whatever you want, I'm anyway
>greatful to you and
On Fri, 2007-08-03 at 11:40 +0800, WANG Cong wrote:
> On Fri, Aug 03, 2007 at 08:47:56AM +0530, Satyam Sharma wrote:
[]
> >While we're talking of null-termination of strings, then I bet you
> >generally want to be using strlcpy(), really. Often strncpy() isn't
> >what you want. Of course, if
On Fri, 2007-08-03 at 11:40 +0800, WANG Cong wrote:
On Fri, Aug 03, 2007 at 08:47:56AM +0530, Satyam Sharma wrote:
[]
While we're talking of null-termination of strings, then I bet you
generally want to be using strlcpy(), really. Often strncpy() isn't
what you want. Of course, if that
On Aug 3 2007 01:30, Guennadi Liakhovetski wrote:
On Fri, 3 Aug 2007, Al Viro wrote:
It doesn't change the fact that use of c[4] or strlen(c) or strcpy(..., c)
means nasal demon country for you.
Haha, funny. You, certainly, may think whatever you want, I'm anyway
greatful to you and to all
Jakub Jelinek wrote:
ISO C99 is very obvious in that the terminating '\0' (resp. L'\0') from
the string literal is only added if there is room in the array or if the
array has unknown size.
I would say C99 is /explicit/ in this regard.
It doesn't seem like an overly /obvious/ language feature
On Fri, 3 Aug 2007 00:09:15 +0100, Al Viro [EMAIL PROTECTED]
said:
On Fri, Aug 03, 2007 at 12:51:16AM +0200, Guennadi Liakhovetski wrote:
On Fri, 3 Aug 2007, Stefan Richter wrote:
Guennadi Liakhovetski wrote:
with
char c[4] = 012345;
the compiler warns, but
Guennadi Liakhovetski wrote:
On Thu, 2 Aug 2007, Randy Dunlap wrote:
C99 spec that Al referred you to (available for around US$18 as a pdf)
says in 6.7.8, para. 14 (where Al said):
"An array of character type may be initialized by a character string literal,
optionally
enclosed in braces.
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
On Fri, Aug 03, 2007 at 08:47:56AM +0530, Satyam Sharma wrote:
>
>
>On Thu, 2 Aug 2007, Jan Engelhardt wrote:
>
>> On Aug 2 2007 21:55, Guennadi Liakhovetski wrote:
>> > [...]
>> >
>> >struct {
>> >char c[4];
>> >int i;
>> >} t;
>> >t.i = 0x12345678;
>> >
On Thu, 2 Aug 2007, Jan Engelhardt wrote:
> On Aug 2 2007 21:55, Guennadi Liakhovetski wrote:
> > [...]
> >
> > struct {
> > char c[4];
> > int i;
> > } t;
> > t.i = 0x12345678;
> > strcpy(t.c, c);
> >
> >and t.i is silently corrupted. Just wanted to ask
On Thu, Aug 02, 2007 at 09:55:51PM +0200, Guennadi Liakhovetski wrote:
> I've run across the following gcc "feature":
>
> char c[4] = "01234";
>
> gcc emits a nice warning
>
> warning: initializer-string for array of chars is too long
>
> But do a
>
> char c[4] = "0123";
>
> and
On 08/03/2007 01:26 AM, Guennadi Liakhovetski wrote:
On Thu, 2 Aug 2007, Randy Dunlap wrote:
C99 spec that Al referred you to (available for around US$18 as a pdf)
says in 6.7.8, para. 14 (where Al said):
"An array of character type may be initialized by a character string
literal,
On Fri, 3 Aug 2007, Al Viro wrote:
> It doesn't change the fact that use of c[4] or strlen(c) or strcpy(..., c)
> means nasal demon country for you.
Haha, funny. You, certainly, may think whatever you want, I'm anyway
greatful to you and to all the rest for the trouble you took to find THE
Al Viro wrote:
> On Fri, Aug 03, 2007 at 12:51:16AM +0200, Guennadi Liakhovetski wrote:
>> On Fri, 3 Aug 2007, Stefan Richter wrote:
>>
>>> Guennadi Liakhovetski wrote:
with
char c[4] = "012345";
the compiler warns, but actually allocates a 6-byte long array...
>>>
On Thu, 2 Aug 2007, Randy Dunlap wrote:
> C99 spec that Al referred you to (available for around US$18 as a pdf)
> says in 6.7.8, para. 14 (where Al said):
>
> "An array of character type may be initialized by a character string literal,
> optionally
> enclosed in braces. Successive characters
On Fri, Aug 03, 2007 at 12:51:16AM +0200, Guennadi Liakhovetski wrote:
> On Fri, 3 Aug 2007, Stefan Richter wrote:
>
> > Guennadi Liakhovetski wrote:
> > > with
> > >
> > > char c[4] = "012345";
> > >
> > > the compiler warns, but actually allocates a 6-byte long array...
> >
> > Off-topic
On Thu, Aug 02, 2007 at 03:54:34PM -0700, Randy Dunlap wrote:
> >
> > And, Stefan, there is a perfect way to specify a "0123" without the '\0' -
> > {'0', '1', '2', '3'}.
>
> We are actually a bit beyond traditional K, fwiw.
Not in that area - this behaviour is precisely what traditional K
had
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
On Fri, 3 Aug 2007, Stefan Richter wrote:
> Guennadi Liakhovetski wrote:
> > with
> >
> > char c[4] = "012345";
> >
> > the compiler warns, but actually allocates a 6-byte long array...
>
> Off-topic here, but: sizeof c / sizeof *c == 4.
Don't think it is OT here - kernel depends on gcc.
On Fri, 3 Aug 2007 00:36:40 +0200 (CEST) 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
Guennadi Liakhovetski wrote:
> Robert, Stefan, I am sorry, I think, you are VERY wrong here.
You meant to say "C99 is very wrong".
> And, Stefan, there is a perfect way to specify a "0123" without the '\0' -
> {'0', '1', '2', '3'}.
C99 says char c[4] = "0123"; is a perfect way to say char c[4]
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,
Guennadi Liakhovetski wrote:
> with
>
> char c[4] = "012345";
>
> the compiler warns, but actually allocates a 6-byte long array...
Off-topic here, but: sizeof c / sizeof *c == 4.
--
Stefan Richter
-=-=-=== =--- ---==
http://arcgraph.de/sr/
-
To unsubscribe from this list: send the
Guennadi Liakhovetski wrote:
> On Thu, 2 Aug 2007, Andi Kleen wrote:
>> 6.7.8.14 of C99:
>> ``
>> An array of character type may be initialized by a character string literal,
>> optionally
>> enclosed in braces. Successive characters of the character string literal
>> (including the
>>
Guennadi Liakhovetski wrote:
On Thu, 2 Aug 2007, Andi Kleen wrote:
Guennadi Liakhovetski <[EMAIL PROTECTED]> writes:
char c[4] = "0123";
and - a wonder - no warning.
It's required by the C standard.
6.7.8.14 of C99:
``
An array of character type may be initialized by a character
On Thu, 2 Aug 2007, Al Viro wrote:
> On Thu, Aug 02, 2007 at 10:26:37PM +0200, Guennadi Liakhovetski wrote:
> >
> > Worse yet, K explicitely writes:
> >
> >
> >
> > char pattern[] = "ould";
> >
> > is a shorthand for the longer but equivalent
> >
> > char pattern[] = { 'o', 'u',
On Thu, Aug 02, 2007 at 10:26:37PM +0200, Guennadi Liakhovetski wrote:
>
> Worse yet, K explicitely writes:
>
>
>
> char pattern[] = "ould";
>
> is a shorthand for the longer but equivalent
>
> char pattern[] = { 'o', 'u', 'l', 'd', '\0' };
>
>
>
> In the latter spelling gcc <
On Thu, 2 Aug 2007, Al Viro wrote:
> On Thu, Aug 02, 2007 at 09:55:51PM +0200, Guennadi Liakhovetski wrote:
> > But do a
> >
> > char c[4] = "0123";
> >
> > and - a wonder - no warning.
>
> And this is a correct behaviour. You get a valid initialier for array;
> see 6.7.8[14] for details.
On Thu, 2 Aug 2007, Andi Kleen wrote:
> Guennadi Liakhovetski <[EMAIL PROTECTED]> writes:
>
> > char c[4] = "0123";
> > and - a wonder - no warning.
>
> It's required by the C standard.
>
> 6.7.8.14 of C99:
> ``
> An array of character type may be initialized by a character string
On Aug 2 2007 21:55, Guennadi Liakhovetski wrote:
>Hi
>
>I've run across the following gcc "feature":
>
> char c[4] = "01234";
>
>gcc emits a nice warning
>
>warning: initializer-string for array of chars is too long
>
>But do a
>
> char c[4] = "0123";
>
>and - a wonder - no warning.
On Thu, 2 Aug 2007, Al Viro wrote:
> On Thu, Aug 02, 2007 at 09:55:51PM +0200, Guennadi Liakhovetski wrote:
> > But do a
> >
> > char c[4] = "0123";
> >
> > and - a wonder - no warning.
>
> And this is a correct behaviour. You get a valid initialier for array;
> see 6.7.8[14] for details.
On Thu, 2 Aug 2007, Jesper Juhl wrote:
> I believe Guennadi's point is that gcc does not warn about it in the
> case of c[4] = "0123"; but only in the case of c[4] = "01234" - so if
> we do have such initializations in the kernel we may have some bugs
> hiding there that gcc doesn't warn us
On 02/08/07, Al Viro <[EMAIL PROTECTED]> wrote:
> On Thu, Aug 02, 2007 at 10:03:03PM +0200, Jesper Juhl wrote:
> > I believe Guennadi's point is that gcc does not warn about it in the
> > case of c[4] = "0123"; but only in the case of c[4] = "01234" - so if
> > we do have such initializations in
Guennadi Liakhovetski <[EMAIL PROTECTED]> writes:
> Hi
>
> I've run across the following gcc "feature":
>
> char c[4] = "01234";
>
> gcc emits a nice warning
>
> warning: initializer-string for array of chars is too long
>
> But do a
>
> char c[4] = "0123";
> and - a wonder - no
On Thu, Aug 02, 2007 at 10:03:03PM +0200, Jesper Juhl wrote:
> I believe Guennadi's point is that gcc does not warn about it in the
> case of c[4] = "0123"; but only in the case of c[4] = "01234" - so if
> we do have such initializations in the kernel we may have some bugs
> hiding there that gcc
On Thu, Aug 02, 2007 at 09:55:51PM +0200, Guennadi Liakhovetski wrote:
> But do a
>
> char c[4] = "0123";
>
> and - a wonder - no warning.
And this is a correct behaviour. You get a valid initialier for array;
see 6.7.8[14] for details. Moreover, that kind of code is often
quite
On 02/08/07, Jan Engelhardt <[EMAIL PROTECTED]> wrote:
>
> On Aug 2 2007 21:55, Guennadi Liakhovetski wrote:
> >Hi
> >
> >I've run across the following gcc "feature":
> >
> > char c[4] = "01234";
> >
> >gcc emits a nice warning
> >
> >warning: initializer-string for array of chars is too
On Aug 2 2007 21:55, Guennadi Liakhovetski wrote:
>Hi
>
>I've run across the following gcc "feature":
>
> char c[4] = "01234";
>
>gcc emits a nice warning
>
>warning: initializer-string for array of chars is too long
>
>But do a
>
> char c[4] = "0123";
>
>and - a wonder - no warning.
Hi
I've run across the following gcc "feature":
char c[4] = "01234";
gcc emits a nice warning
warning: initializer-string for array of chars is too long
But do a
char c[4] = "0123";
and - a wonder - no warning. No warning with gcc 3.3.2, 3.3.5, 3.4.5,
4.1.2. I was told
Hi
I've run across the following gcc feature:
char c[4] = 01234;
gcc emits a nice warning
warning: initializer-string for array of chars is too long
But do a
char c[4] = 0123;
and - a wonder - no warning. No warning with gcc 3.3.2, 3.3.5, 3.4.5,
4.1.2. I was told 4.2.x does
On Aug 2 2007 21:55, Guennadi Liakhovetski wrote:
Hi
I've run across the following gcc feature:
char c[4] = 01234;
gcc emits a nice warning
warning: initializer-string for array of chars is too long
But do a
char c[4] = 0123;
and - a wonder - no warning. No warning with gcc
On 02/08/07, Jan Engelhardt [EMAIL PROTECTED] wrote:
On Aug 2 2007 21:55, Guennadi Liakhovetski wrote:
Hi
I've run across the following gcc feature:
char c[4] = 01234;
gcc emits a nice warning
warning: initializer-string for array of chars is too long
But do a
On Thu, Aug 02, 2007 at 09:55:51PM +0200, Guennadi Liakhovetski wrote:
But do a
char c[4] = 0123;
and - a wonder - no warning.
And this is a correct behaviour. You get a valid initialier for array;
see 6.7.8[14] for details. Moreover, that kind of code is often
quite deliberate.
On Thu, Aug 02, 2007 at 10:03:03PM +0200, Jesper Juhl wrote:
I believe Guennadi's point is that gcc does not warn about it in the
case of c[4] = 0123; but only in the case of c[4] = 01234 - so if
we do have such initializations in the kernel we may have some bugs
hiding there that gcc doesn't
On 02/08/07, Al Viro [EMAIL PROTECTED] wrote:
On Thu, Aug 02, 2007 at 10:03:03PM +0200, Jesper Juhl wrote:
I believe Guennadi's point is that gcc does not warn about it in the
case of c[4] = 0123; but only in the case of c[4] = 01234 - so if
we do have such initializations in the kernel we
Guennadi Liakhovetski [EMAIL PROTECTED] writes:
Hi
I've run across the following gcc feature:
char c[4] = 01234;
gcc emits a nice warning
warning: initializer-string for array of chars is too long
But do a
char c[4] = 0123;
and - a wonder - no warning.
It's
On Thu, 2 Aug 2007, Jesper Juhl wrote:
I believe Guennadi's point is that gcc does not warn about it in the
case of c[4] = 0123; but only in the case of c[4] = 01234 - so if
we do have such initializations in the kernel we may have some bugs
hiding there that gcc doesn't warn us about.
On Aug 2 2007 21:55, Guennadi Liakhovetski wrote:
Hi
I've run across the following gcc feature:
char c[4] = 01234;
gcc emits a nice warning
warning: initializer-string for array of chars is too long
But do a
char c[4] = 0123;
and - a wonder - no warning. No warning with gcc
On Thu, 2 Aug 2007, Al Viro wrote:
On Thu, Aug 02, 2007 at 09:55:51PM +0200, Guennadi Liakhovetski wrote:
But do a
char c[4] = 0123;
and - a wonder - no warning.
And this is a correct behaviour. You get a valid initialier for array;
see 6.7.8[14] for details. Moreover, that
On Thu, 2 Aug 2007, Andi Kleen wrote:
Guennadi Liakhovetski [EMAIL PROTECTED] writes:
char c[4] = 0123;
and - a wonder - no warning.
It's required by the C standard.
6.7.8.14 of C99:
``
An array of character type may be initialized by a character string literal,
optionally
On Thu, 2 Aug 2007, Al Viro wrote:
On Thu, Aug 02, 2007 at 09:55:51PM +0200, Guennadi Liakhovetski wrote:
But do a
char c[4] = 0123;
and - a wonder - no warning.
And this is a correct behaviour. You get a valid initialier for array;
see 6.7.8[14] for details. Moreover, that
On Thu, Aug 02, 2007 at 10:26:37PM +0200, Guennadi Liakhovetski wrote:
Worse yet, KR explicitely writes:
quote
char pattern[] = ould;
is a shorthand for the longer but equivalent
char pattern[] = { 'o', 'u', 'l', 'd', '\0' };
/quote
In the latter spelling gcc 4.2
On Thu, 2 Aug 2007, Al Viro wrote:
On Thu, Aug 02, 2007 at 10:26:37PM +0200, Guennadi Liakhovetski wrote:
Worse yet, KR explicitely writes:
quote
char pattern[] = ould;
is a shorthand for the longer but equivalent
char pattern[] = { 'o', 'u', 'l', 'd', '\0' };
Guennadi Liakhovetski wrote:
On Thu, 2 Aug 2007, Andi Kleen wrote:
Guennadi Liakhovetski [EMAIL PROTECTED] writes:
char c[4] = 0123;
and - a wonder - no warning.
It's required by the C standard.
6.7.8.14 of C99:
``
An array of character type may be initialized by a character
Guennadi Liakhovetski wrote:
On Thu, 2 Aug 2007, Andi Kleen wrote:
6.7.8.14 of C99:
``
An array of character type may be initialized by a character string literal,
optionally
enclosed in braces. Successive characters of the character string literal
(including the
terminating null
Guennadi Liakhovetski wrote:
with
char c[4] = 012345;
the compiler warns, but actually allocates a 6-byte long array...
Off-topic here, but: sizeof c / sizeof *c == 4.
--
Stefan Richter
-=-=-=== =--- ---==
http://arcgraph.de/sr/
-
To unsubscribe from this list: send the line
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,
On Fri, Aug 03, 2007 at 12:51:16AM +0200, Guennadi Liakhovetski wrote:
On Fri, 3 Aug 2007, Stefan Richter wrote:
Guennadi Liakhovetski wrote:
with
char c[4] = 012345;
the compiler warns, but actually allocates a 6-byte long array...
Off-topic here, but: sizeof c /
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
On Fri, 3 Aug 2007 00:36:40 +0200 (CEST) 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
Guennadi Liakhovetski wrote:
Robert, Stefan, I am sorry, I think, you are VERY wrong here.
You meant to say C99 is very wrong.
And, Stefan, there is a perfect way to specify a 0123 without the '\0' -
{'0', '1', '2', '3'}.
C99 says char c[4] = 0123; is a perfect way to say char c[4] = {'0',
On Fri, 3 Aug 2007, Stefan Richter wrote:
Guennadi Liakhovetski wrote:
with
char c[4] = 012345;
the compiler warns, but actually allocates a 6-byte long array...
Off-topic here, but: sizeof c / sizeof *c == 4.
Don't think it is OT here - kernel depends on gcc. And, what I
On Thu, Aug 02, 2007 at 03:54:34PM -0700, Randy Dunlap wrote:
And, Stefan, there is a perfect way to specify a 0123 without the '\0' -
{'0', '1', '2', '3'}.
We are actually a bit beyond traditional KR, fwiw.
Not in that area - this behaviour is precisely what traditional KR
had all
On Thu, 2 Aug 2007, Randy Dunlap wrote:
C99 spec that Al referred you to (available for around US$18 as a pdf)
says in 6.7.8, para. 14 (where Al said):
An array of character type may be initialized by a character string literal,
optionally
enclosed in braces. Successive characters of the
On 08/03/2007 01:26 AM, Guennadi Liakhovetski wrote:
On Thu, 2 Aug 2007, Randy Dunlap wrote:
C99 spec that Al referred you to (available for around US$18 as a pdf)
says in 6.7.8, para. 14 (where Al said):
An array of character type may be initialized by a character string
literal,
On Thu, Aug 02, 2007 at 09:55:51PM +0200, Guennadi Liakhovetski wrote:
I've run across the following gcc feature:
char c[4] = 01234;
gcc emits a nice warning
warning: initializer-string for array of chars is too long
But do a
char c[4] = 0123;
and - a wonder - no
On Fri, 3 Aug 2007, Al Viro wrote:
It doesn't change the fact that use of c[4] or strlen(c) or strcpy(..., c)
means nasal demon country for you.
Haha, funny. You, certainly, may think whatever you want, I'm anyway
greatful to you and to all the rest for the trouble you took to find THE
quote
Al Viro wrote:
On Fri, Aug 03, 2007 at 12:51:16AM +0200, Guennadi Liakhovetski wrote:
On Fri, 3 Aug 2007, Stefan Richter wrote:
Guennadi Liakhovetski wrote:
with
char c[4] = 012345;
the compiler warns, but actually allocates a 6-byte long array...
Off-topic here, but: sizeof c /
On Thu, 2 Aug 2007, Jan Engelhardt wrote:
On Aug 2 2007 21:55, Guennadi Liakhovetski wrote:
[...]
struct {
char c[4];
int i;
} t;
t.i = 0x12345678;
strcpy(t.c, c);
and t.i is silently corrupted. Just wanted to ask if this is known,
On Fri, Aug 03, 2007 at 08:47:56AM +0530, Satyam Sharma wrote:
On Thu, 2 Aug 2007, Jan Engelhardt wrote:
On Aug 2 2007 21:55, Guennadi Liakhovetski wrote:
[...]
struct {
char c[4];
int i;
} t;
t.i = 0x12345678;
strcpy(t.c, c);
and t.i is
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
Guennadi Liakhovetski wrote:
On Thu, 2 Aug 2007, Randy Dunlap wrote:
C99 spec that Al referred you to (available for around US$18 as a pdf)
says in 6.7.8, para. 14 (where Al said):
An array of character type may be initialized by a character string literal,
optionally
enclosed in braces.
74 matches
Mail list logo