This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Gcc and char type
- To: bug-gcc at gnu dot org
- Subject: Gcc and char type
- From: Alain Degreffe <eczema at ecze dot com>
- Date: Fri, 26 May 2000 10:08:45 +0200
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