g++ segmentation fault

Florian Lohoff flo at rfc822.org
Wed Apr 26 15:54:01 CEST 2000


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
-- 
Florian Lohoff		flo at rfc822.org		      	+49-subject-2-change
"Technology is a constant battle between manufacturers producing bigger and
more idiot-proof systems and nature producing bigger and better idiots."


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



More information about the Linux mailing list