On Thursday 25 February 2010 23:46:03 Dag-Erling Smørgrav wrote:
> "Matthias Andree" <[email protected]> writes:
> > Dag-Erling Smørgrav <[email protected]> writes:
> > > char a[9] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i' };
> >
> > char a[9] = "abcdefghi";
> >
> > suffices. The compiler knows there isn't room for the terminal '\0'
> > and omits it.
> 
> Some compilers (gcc at least) warn about it.

It shouldn't.  C99 explicitly has this as an example (6.7.8.32).  It's also of 
note that
  char *p = "abc"
is different from
  char a[] = "abc"
in that the elements of a are modifiable, while modifying p[x] yields 
undefined behavior.

But this is increasingly getting out of scope for hackers@ ... so I'll shut up 
now.

--
  Max
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[email protected]"

Reply via email to