On Tue, 5 Jun 2007, Hugh McIntyre wrote:
girish wrote:
Can someone please explain why this program works in sunstudio C compiler
but seg faults in gcc:
You can get a segmentation fault with Studio as well if you use -xstrconst.
Guess why?
Hugh.
PS: there is probably some GCC option to turn this off. Maybe.
Used to be "-fwriteable-strings" but recent GCC versions (rightfully so)
dumped that.
FrankH.
#include <stdio.h>
#include <string.h>
int
main()
{
char *ptr = "adam";
strcpy(ptr, "eve");
printf("%s\n", ptr);
}
This message posted from opensolaris.org
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code