Please move this discussion to the gcc-help mailing list where it belongs. I'll reply on that list instead.
On Tue, 28 Apr 2020 at 07:07, luo alvin <alvin...@hotmail.com> wrote: > > Thank you very much for replying me. I also think it not bug,because I test > this code in the lower version(lower than 8.3.1-3) of gcc,all cause segment > fault. The funny thing is that if you run this code higher than gcc > version(8.3.1-4)(actually I only test code in the version 8.3.1-4),the result > is fine(doesn’t lead to segment fault).furthermore, I found that the value of > sizeof(std::string) is different between gcc versions. Value in version > 8.3.1-3 is 8 ,and 32 in version 8.3.1-4. > > 发送自 Windows 10 版邮件应用 > > > > 发件人: Jonathan Wakely > 发送时间: 2020年4月28日 13:56 > 收件人: luo alvin > 抄送: gcc@gcc.gnu.org > 主题: Re: segment fault > > > > On Tue, 28 Apr 2020 at 02:26, luo alvin via Gcc <gcc@gcc.gnu.org> wrote: > > > > Dear gnu: > > Here is code: > > Please do not report bugs to this mailing list. Bug reports belong in > our Bugzilla database, see https://gcc.gnu.org/bugs/ > > But this is not a bug anyway, your code has undefined behaviour. You > cannot use memset on non-trivial objects. Using memset like that > overwrites the contents of the std::string with invalid data. > >