On Tue, 2005-04-19 at 09:53 +0300, Amir Binyamini wrote:
> Well , what I said , and I repeating it now , is :
>
> Take a little program like this:
>
> int main()
> {
> char* test = "ab";
> (*test)++;
>
> printf("finished\n");
> }
>
> Compiling it with gcc on RefHat Linux an running it gives a segmentation
> fault.
>
>
> On the other hand,if instead (*test)++ you'll write
> char c = *test;
> c++;
>
> It will not crash.
Ok, this is because the two are not equivalent. the former mutates
'test' in place - which if its in the .text isn't permitted. Recent gccs
uniquify strings and put them in .text. If you pass -fwriteable-strings
to gcc, the former version will work.
Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
signature.asc
Description: This is a digitally signed message part
-- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
