Gcc and char type
Alain Degreffe
eczema@ecze.com
Fri May 26 02:06:00 GMT 2000
Hi,
I try to compile some simple program under linux with the gcc
compiler and i have got some problems...
In fact, the gcc doesn't compile c source code like other unix compiler.
Here a simple program:
------------------------------------------------
#include <stdio.h>
char t1[] = "xxx" ;
char *t2 ;
char *t3 = "yyy" ;
main()
{
printf ("begin\n");
t1[0] = 'A' ; /* OK */
printf("t1 = %s\n",t1);
t2 = &t1[0];
t2[0] = 'A' ; /* OK */
printf("t2 = %s\n",t2);
t3[0] = 'A'; /* Segmentation violation : Oops ! Wht ? */
printf("t3 = %s\n",t3);
}
-------------------------------------------------
Begin
t1 = Axxx
t2 = Axxx
core dumped....
It's just impossible to reproduce this ?bug? on many cCompilers (
Borland C for Windows , C on Unix-> Aix, Sco, ... )
--------------------------------------------------
Is it really a bug ?
What's the problem ?
Thanks
Alain Degreffe
Eczema@ecze.com
More information about the Gcc-bugs
mailing list