Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!henry
From: henry@utzoo.UUCP (Henry Spencer)
Newsgroups: net.lang.c
Subject: Re: String help!
Message-ID: <5162@utzoo.UUCP>
Date: Mon, 4-Mar-85 16:05:42 EST
Article-I.D.: utzoo.5162
Posted: Mon Mar  4 16:05:42 1985
Date-Received: Mon, 4-Mar-85 16:05:42 EST
References: <8257@watarts.UUCP> <929@ukma.UUCP> <437@ark.UUCP> <194@rtech.ARPA>, <7027@watdaisy.UUCP>
Organization: U of Toronto Zoology
Lines: 19

> > In DEC C, string constants are read-only.  They are in a special, write-
> > protected psect.  If you try to do something like the above, you will
> > get a run-time error.  --  Jeff Lichtman
> 
> What does the standard say about this?  Can an implementation legally prevent
> a C program from modifying storage accessed by a valid pointer?

The latest ANSI draft (11 Feb 1985) says that string literals are of
type "const char[]" (not just "char[]") and thus it is illegal for you
to alter their contents.  This has both advantages and disadvantages.
It will break some programs, notably ones that use mktemp() in the
most simplistic way.  On the other hand, it will produce widespread
(if modest) improvements in efficiency, and will make life noticeably
easier for people writing C code to go in ROM.  [Please, let us not
have a renewed debate on the merits or lack thereof of this change;
we did that, at length, a few months ago.]
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry