V
Victor Irzak
Hello!
This program causes seg fault on gcc, but executes fine on icc and VC7.
Is there a reason for it or is it a bug?
Note: if "char * const str" is changed to "char * str", the gcc problem disappears.
#include "stdio.h"
int main() {
char * const str="ya";
char *first = &str[0], *second =&str[1];
char tmp;
printf("%s\n", str);
tmp = *first;
*first = *second;
*second = tmp;
printf("%s\n", str);
return 0;
}
This program causes seg fault on gcc, but executes fine on icc and VC7.
Is there a reason for it or is it a bug?
Note: if "char * const str" is changed to "char * str", the gcc problem disappears.
#include "stdio.h"
int main() {
char * const str="ya";
char *first = &str[0], *second =&str[1];
char tmp;
printf("%s\n", str);
tmp = *first;
*first = *second;
*second = tmp;
printf("%s\n", str);
return 0;
}