public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: luo alvin <alvinlmf@hotmail.com>
To: Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: 回复: segment fault
Date: Tue, 28 Apr 2020 08:47:07 +0000	[thread overview]
Message-ID: <HK0PR01MB20811746B2CED058A3B5D4FCD4AC0@HK0PR01MB2081.apcprd01.prod.exchangelabs.com> (raw)
In-Reply-To: <CAH6eHdQSd1v8o4hSazRCjKmSZH9wJACH6dfadNJ7+8NPVQnLgw@mail.gmail.com>

Thank you very much ,you help me a lot!

发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用

________________________________
发件人: Jonathan Wakely <jwakely.gcc@gmail.com>
发送时间: Tuesday, April 28, 2020 4:45:10 PM
收件人: luo alvin <alvinlmf@hotmail.com>
抄送: gcc-help <gcc-help@gcc.gnu.org>
主题: Re: segment fault

On Tue, 28 Apr 2020 at 07:07, luo alvin <alvinlmf@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).

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.

      reply	other threads:[~2020-04-28  8:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <HK0PR01MB20814473ACEDD5F20C7200F1D4AC0@HK0PR01MB2081.apcprd01.prod.exchangelabs.com>
     [not found] ` <CAH6eHdRn9U8HnQzvbDChxRmVh956PpPUqvYjrM1yPCge44Zu1w@mail.gmail.com>
     [not found]   ` <HK0PR01MB20811B1F43D6E93889C70430D4AC0@HK0PR01MB2081.apcprd01.prod.exchangelabs.com>
2020-04-28  8:45     ` Jonathan Wakely
2020-04-28  8:47       ` luo alvin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=HK0PR01MB20811746B2CED058A3B5D4FCD4AC0@HK0PR01MB2081.apcprd01.prod.exchangelabs.com \
    --to=alvinlmf@hotmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=jwakely.gcc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).