g++ segmentation fault
Uwe Schuerkamp
hoover at qubiz.com
Wed Apr 26 15:16:45 CEST 2000
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.
Uwe
--
Uwe Schuerkamp, QuBiz GmbH Phone: +49 5241 80 10 66
An der Autobahn 18, 33311 Guetersloh uwe.schuerkamp at qubiz.com
PGP Fingerprint: 2E 13 20 22 9A 3F 63 7F 67 6F E9 B1 A8 36 A4 61
-
Hinweise zur Benutzung dieser (und anderer Mailing-Listen) bitte beachten:
--> http://lug-owl.de/mailinglist_hints.html <--
More information about the Linux
mailing list