public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "slyfox at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/98499] [11 Regression] Possibly bad std::string initialization in constructors
Date: Sun, 03 Jan 2021 20:56:00 +0000	[thread overview]
Message-ID: <bug-98499-4-1wa9ULK6OI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98499-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98499

--- Comment #3 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
`--param=modref-max-depth=0` makes the bug disappear.

Looking at `-fdump-tree-all` the harmful optimization happens at `107.fre3`
where:

```
  if (&MEM[(struct string *)&D.2237 + 48B]._M_local_buf != _17)
    goto <bb 3>; [0.00%]
  else
    goto <bb 4>; [100.00%]

  <bb 3> [count: 0]:
  __builtin_trap ();
```

is converted into an unconditional `__builtin_trap ();`. `-fdump-tree-all-all`
says it's a constant fold:

```
Value numbering stmt = if (&MEM[(struct string *)&D.2237 + 48B]._M_local_buf !=
_17)
Applying pattern match.pd:4920, gimple-match.c:3373
marking known outgoing edge 2 -> 3 executable
Block 1: BB4 found not executable
...
```

It looks like it's constant-folded into always-true instead of expected
always-false. `match.pd:4920` is a `pta`:

```
/* Simplify pointer equality compares using PTA.  */
(for neeq (ne eq)
 (simplify
  (neeq @0 @1)
  (if (POINTER_TYPE_P (TREE_TYPE (@0))
       && ptrs_compare_unequal (@0, @1))
   { constant_boolean_node (neeq != EQ_EXPR, type); })))
```

`036t.ealias` and `043t.modref1` says `--param=modref-max-depth=0` has the
effect on how many things escape from main(), but I don't understand the
output.

  parent reply	other threads:[~2021-01-03 20:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-02 11:11 [Bug c++/98499] New: " slyfox at gcc dot gnu.org
2021-01-02 22:22 ` [Bug c++/98499] " slyfox at gcc dot gnu.org
2021-01-03 11:44 ` slyfox at gcc dot gnu.org
2021-01-03 20:56 ` slyfox at gcc dot gnu.org [this message]
2021-01-03 21:50 ` slyfox at gcc dot gnu.org
2021-01-04 12:28 ` marxin at gcc dot gnu.org
2021-01-05 11:09 ` rguenth at gcc dot gnu.org
2021-01-06 23:11 ` [Bug tree-optimization/98499] " slyfox at gcc dot gnu.org
2021-01-07  8:12 ` rguenth at gcc dot gnu.org
2021-01-10 18:39 ` slyfox at gcc dot gnu.org
2021-01-28 10:55 ` hubicka at gcc dot gnu.org
2021-01-30 18:02 ` slyfox at gcc dot gnu.org
2021-02-01 18:14 ` cvs-commit at gcc dot gnu.org
2021-02-01 18:39 ` slyfox at gcc dot gnu.org
2021-02-01 18:40 ` slyfox at gcc dot gnu.org

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=bug-98499-4-1wa9ULK6OI@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).