This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Gcc and char type


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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]