Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site sdcsvax.UUCP Path: utzoo!linus!decvax!ittvax!dcdwest!sdcsvax!greg From: greg@sdcsvax.UUCP Newsgroups: net.unix-wizards Subject: Re: pcc shared string question Message-ID: <1055@sdcsvax.UUCP> Date: Thu, 26-Jul-84 14:37:36 EDT Article-I.D.: sdcsvax.1055 Posted: Thu Jul 26 14:37:36 1984 Date-Received: Sat, 28-Jul-84 06:02:04 EDT References: <106@msdc.UUCP> Organization: NCR Corporation, Torrey Pines Lines: 25 In article <106@msdc.UUCP> dan@msdc.UUCP (Dan Forsyth) writes: >None of the libraries ever modify double-quoted literals .... So, >what kind of trouble am I buying here? What have I missed? Close. The original implementation of our compiler put double-quoted strings in text space and we got along just fine for months. However, although nowhere in the LIBRARIES are double-quoted literals modified, at least one UTILITY does. The offending utility is "ed" which has: tfname = mktemp("/tmp/eXXXXXX"); in it. Mktemp() blissfully stomps on the string passed to it, so this will modify the literal. I'd argue that this is bad coding practice, but in the end, we put our strings in the data segment to be compatible with the rest of the C community. (My feeling is that literals should be literal (i.e., mean what they say) and thus should NOT be modifyable.) Other than dangers like that, you should be perfectly safe in putting your strings in the text area. I'd be curious to know if you encounter any other problems. Does anybody know what the proposed C standard has to say on the subject? I'd be willing to propose that literals (as opposed to initializers) be read-only by default, as if they had the "const" attribute. Anybody have any other thoughts on the subject? -- -- Greg Noel, NCR Torrey Pines Greg@sdcsvax.UUCP or Greg@nosc.ARPA