Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jan 2001 17:12:12 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Tony Finch <dot@dotat.at>
Cc:        Matthew Jacob <mjacob@feral.com>, =?iso-8859-1?Q?G=E9rard_Roudier?= <groudier@club-internet.fr>, Peter Wemm <peter@netplex.com.au>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/dev/isp isp.c
Message-ID:  <Pine.BSF.4.21.0101041707400.14622-100000@besplex.bde.org>
In-Reply-To: <20010103231258.F6550@hand.dotat.at>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 3 Jan 2001, Tony Finch wrote:

> Bruce Evans <bde@zeta.org.au> wrote:
> >
> >Actually, literal strings are arrays of plain chars.
> 
> Gah!
> 
> >Their non-modifyability is specified explicitly since it doesn't
> >follow from const'ness.
> 
> Why doesn't it follow? The C standard uses pretty much the same
> language to say that string literals and const objects shouldn't be
> modified ("behaviour is undefined"). [I'm looking at the C99 draft.]

Because plain chars aren't const.  If they were then the standard
wouldn't have to repeat these words for string literals.

> >Enforcement of const'ness is also optional.  The non-const'ness of the
> >chars in literal strings gives implementors even more freedom.  E.g.:
> >
> >---
> >void foo(char *);
> >char *bar;
> >...
> >	foo(bar);			/* Diagnostic required. */
> >	foo("string literal");		/* Diagnostic not required. */
> >---
> 
> Was there supposed to be a const in there somewhere?

Oops, `bar' should have been `const char *'.

> >Use `gcc -Wwrite-strings' if you don't want warnings for possibly
> >modifying string literals.
> 
> Surely "... if you do want ..."?

More oops.

Bruce



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0101041707400.14622-100000>