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/41318] Access to char * generates segmentation fault



------- 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


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