Thank you very much ,you help me a lot! 发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用 ________________________________ 发件人: Jonathan Wakely <jwakely.gcc@xxxxxxxxx> 发送时间: Tuesday, April 28, 2020 4:45:10 PM 收件人: luo alvin <alvinlmf@xxxxxxxxxxx> 抄送: gcc-help <gcc-help@xxxxxxxxxxx> 主题: Re: segment fault On Tue, 28 Apr 2020 at 07:07, luo alvin <alvinlmf@xxxxxxxxxxx> 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). Your program has undefined behaviour. That means anything can happen. >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. That is not caused by the GCC version, it's caused by a different default for the _GLIBCXX_USE_CXX11_ABI macro. When the default is 0 sizeof(std::string) == sizeof(char*) but when the default is 1 sizeof(string) is larger. See https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html for more information about the macro.