g++ segmentation fault

Dietmar Guhe dguhe at Mathematik.Uni-Bielefeld.DE
Wed Apr 26 16:35:12 CEST 2000


On Wed, 26 Apr 2000, Uwe Schuerkamp wrote:

> Date: Wed, 26 Apr 2000 15:16:45 +0200
> From: Uwe Schuerkamp <hoover at qubiz.com>
> To: Florian Lohoff <flo at rfc822.org>
> Cc: Thomas Balls-Thies <thomas.balls-thies at uni-bielefeld.de>,
     "linux at lug-owl.de" <linux at lug-owl.de>
> Subject: Re: g++ segmentation fault
> 
> On Wed, Apr 26, 2000 at 03:54:01PM +0200, Florian Lohoff wrote:
> > On Wed, Apr 26, 2000 at 03:50:05PM +0200, Thomas Balls-Thies wrote:
> > > Thomas Balls-Thies wrote:
> > > >
> > > > Schon klarer. Mit char a[5]; läuft das Programm jetzt.
> > > 
> > > Quatsch, was ich da schrieb: mit char a[]="text" läuft das Programm.
> > > 
> > > Wobei sich mir die Frage stellt warum a[] und nicht *a?
> > 
> > Weil der compiler bei
> > 
> > char a* = "text";
> > 
> > Text als "const" ablegt - d.h. in einem read-only segment.
> > 
> > Bei 
> > 
> > char a[] = "text";
> > 
> > aber auf den stack oder zumindest in einen read-write bereich.
> > 
> > Warum der compiler das macht *zuck mit den achseln*  - Dafuer muesste
> > man sich jetzt genauer damit auseinandersetzen. Es gibt bestimmt
> > auch ein compilerflag mit dem man das abstellen kann.
> > 
> > Flo
> 
> Aus "man gcc": 
> 
> 
> 
> -fwritable-strings 
> 
> Store string constants in the writable data
> segment and don't uniquize them.  This is for compatibility
> with old programs which assume they can write into
> string constants.  -traditional' also has this ef­
> fect.
> 
> Writing into string constants is a very bad idea; "constants"
> should be constant.

Super. Gut zu wissen. 

Dietmar (, der gerne ein bischen mehr ueber C wuesste.)

-- 
Windows User vs. Linux User: 
Die einen befolgen (legen Sie die .. in Laufwerk .. ein)
und die anderen geben (mount ..) Anweisungen.
http://www.mathematik.uni-bielefeld.de/~dguhe/
------------------------------------------------------



-
Hinweise zur Benutzung dieser (und anderer Mailing-Listen) bitte beachten:
--> http://lug-owl.de/mailinglist_hints.html <--



More information about the Linux mailing list