From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: luo alvin <alvinlmf@hotmail.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: segment fault
Date: Tue, 28 Apr 2020 09:45:10 +0100 [thread overview]
Message-ID: <CAH6eHdQSd1v8o4hSazRCjKmSZH9wJACH6dfadNJ7+8NPVQnLgw@mail.gmail.com> (raw)
In-Reply-To: <HK0PR01MB20811B1F43D6E93889C70430D4AC0@HK0PR01MB2081.apcprd01.prod.exchangelabs.com>
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.
next parent reply other threads:[~2020-04-28 8:45 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 [this message]
2020-04-28 8:47 ` 回复: " luo alvin
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=CAH6eHdQSd1v8o4hSazRCjKmSZH9wJACH6dfadNJ7+8NPVQnLgw@mail.gmail.com \
--to=jwakely.gcc@gmail.com \
--cc=alvinlmf@hotmail.com \
--cc=gcc-help@gcc.gnu.org \
/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).