This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/41318] Access to char * generates segmentation fault
- From: "hxdg21 at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Sep 2009 03:09:26 -0000
- Subject: [Bug c/41318] Access to char * generates segmentation fault
- References: <bug-41318-18171@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from hxdg21 at yahoo dot com 2009-09-30 03:09 -------
Thank you for the clarification. My friend and I ran across this while
comparing the assembly generated by different compilers/platforms when
manipulating strings. A largely academic exercise. That piece of code did not
look right to me at first but what threw us off is the fact that the code
worked with the Sun compiler and that -Wall -pedantic on gcc did not give us
any warnings. We were puzzled by it.
You are correct though. I checked the standard and it does specify that the
result of such operation is undefined, which explains why it may work with some
compilers but certainly something that shouldn't be relied on.
Thanks again
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41318