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]
Other format: [Raw text]

[Bug c/64187] Writing to a char array cast from a char * causes a segmentation fault


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64187

--- Comment #2 from Brian <brian.corriveau at ericsson dot com> ---
(In reply to Andrew Pinski from comment #1)
>     char *test = "this is a test";
> 
> 
> This is a string literal so it stored in constant memory and which is why
> you are getting a segfault.

I was thinking "test" would be on the stack, but obviously not.

I did compile with the -Wall option before filing the bug, but I didn't get any
complaints. Maybe this is something that could be improved.

thanks for the speedy answer,
brian


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