From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3AE7A3857C6D; Sun, 3 Jan 2021 20:56:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3AE7A3857C6D From: "slyfox at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: slyfox at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jan 2021 20:56:00 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98499 --- Comment #3 from Sergei Trofimovich --- `--param=3Dmodref-max-depth=3D0` 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 !=3D _17) goto ; [0.00%] else goto ; [100.00%] [count: 0]: __builtin_trap (); ``` is converted into an unconditional `__builtin_trap ();`. `-fdump-tree-all-a= ll` says it's a constant fold: ``` Value numbering stmt =3D if (&MEM[(struct string *)&D.2237 + 48B]._M_local_= buf !=3D _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 !=3D EQ_EXPR, type); }))) ``` `036t.ealias` and `043t.modref1` says `--param=3Dmodref-max-depth=3D0` has = the effect on how many things escape from main(), but I don't understand the output.=