Gcc and char type

Nathan Sidwell nathan@codesourcery.com
Fri May 26 02:57:00 GMT 2000


Alain Degreffe wrote:

> In fact, the gcc doesn't compile c source code like other unix compiler.
>From your output, gcc has compiled it, you're getting the seg fault
when you run it.
> 
> Begin
> t1 = Axxx
> t2 = Axxx
> core dumped....


> char *t3 = "yyy" ;

>     t3[0] = 'A';  /* Segmentation violation : Oops ! Wht ? */
You are attempting to modify a string constant. This invokes undefined
behaviour. Not a bug in gcc.
see http://www.eskimo.com/~scs/C-faq/q1.32.html

nathan

-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org


More information about the Gcc-bugs mailing list