🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #49585

Re: gcc bug?

#49585
From: Richard Earnshaw
Date: Sat, 08 Jan 1994 12:46
34 lines
1746 bytes
In article <MML.94Jan7135716@trinity.trinity.llnl.gov>, mml@trinity.trinity.llnl.gov ( Mitch M. Lee ) writes:
|> 
|> For some reason, when I compile the following with
|> gcc, it does not work. However when I compile with 
|> cc, it works as expected. Anyone know why? Perhaps
|> I'm not seeing something trivial here?
|> =================================================
|> #include <stdio.h>
|> #include <strings.h>  
|> #include <ctype.h>
|> 
|> char *stringtoupper(s)
|> char *s;
|> {
|> 
|>   while (*s != '\0') {
|>      *s = toupper(*s);
|>      s++;
|>   }
|> }
|> 
|> main()
|> { 
|>   printf("%s\n", stringtoupper("My test"));
|>   printf("%s\n", stringtoupper("works"));
|> }

You are trying to modify constant strings.  GCC won't let you do that unless
you compile with -fwriteable-strings; this forces gcc to put the strings into
the data segment, rather than a read-only segment and means that duplicated
strings can't be eliminated.

It's generally a bad idea to write code that depends on constant strings being
writeable in this way.
Technical Details
Message-ID: <CJBA64.C53@cs.utwente.nl>
Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!EU.net!sun4nl!utciva.civ.utwente.nl!infnews.cs.utwente.nl!rwe
References: <MML.94Jan7135716@trinity.trinity.llnl.gov>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,32c345ab94e214c5
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1994-01-08 05:07:17 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!EU.net!sun4nl!utciva.civ.utwente.nl!infnews.cs.utwente.nl!rwe
From: rwe@cs.utwente.nl (Richard Earnshaw)
Subject: Re: gcc bug?
Message-ID: <CJBA64.C53@cs.utwente.nl>
Sender: usenet@cs.utwente.nl
Nntp-Posting-Host: hangjas.pegasus.esprit.ec.org
Organization: University of Twente, Dept. of Computer Science
References:  <MML.94Jan7135716@trinity.trinity.llnl.gov>
Distribution: gnu
Date: Sat, 8 Jan 1994 12:46:52 GMT
Lines: 34