From owner-cvs-all Wed Jan 3 22:11:47 2001 From owner-cvs-all@FreeBSD.ORG Wed Jan 3 22:11:44 2001 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 0967237B400; Wed, 3 Jan 2001 22:11:43 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id RAA25282; Thu, 4 Jan 2001 17:11:21 +1100 Date: Thu, 4 Jan 2001 17:12:12 +1100 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Tony Finch Cc: Matthew Jacob , =?iso-8859-1?Q?G=E9rard_Roudier?= , Peter Wemm , cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/dev/isp isp.c In-Reply-To: <20010103231258.F6550@hand.dotat.at> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, 3 Jan 2001, Tony Finch wrote: > Bruce Evans 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