This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/64187] Writing to a char array cast from a char * causes a segmentation fault
- From: "brian.corriveau at ericsson dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 04 Dec 2014 21:49:31 +0000
- Subject: [Bug c/64187] Writing to a char array cast from a char * causes a segmentation fault
- Auto-submitted: auto-generated
- References: <bug-64187-4 at http dot gcc dot gnu dot org/bugzilla/>
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