segfault with gcc, but not with TC
Consider the following program.
Code:
#include <stdio.h>
int main()
{
char *a = "Hello";
a[2] = 'a';
return 0;
}
This program compiles fine, without any error/warning messages. On TC it even executes okay(if I print the string pointed to by a, it prints Healo), however with gcc on execution it gives a segmentation fault.
Now I know that TC and gcc are different in some ways like :
1) TC uses 16 bit pointers while gcc uses 32 bit pointers
2) gcc conforms to the ansi version of C, more that TC
I may be wrong about these differences but this is what I know.
Whatever the differences may be, I could not understand why it gives the segfault error with gcc.
Help needed.