From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 65BA63857C44; Mon, 20 Feb 2023 18:33:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 65BA63857C44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676918000; bh=+C6MuJL25MenzbvYvgKuapcuyj0aEbmhPG+xUzdzkdk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MkBgrGl7pTMUTwrP7N93577eIz9tDZJs2Q+rKc+WPqkt3nXb0JjWC0Ohoer6sNdVH 9gbFTEv2cuH0doKoPf4KcOWkwdgum2lmvCICsW/+ysUh8ljk/uJdkdltNMPMubE/aR l1FUxrURW3mZwDAVpidOVrJCl9UUS5BLMgafHK4w= From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108243] [10/11/12/13 Regression] Missed optimization for static const std::string_view(const char*) Date: Mon, 20 Feb 2023 18:33:18 +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.3.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: ppalka at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108243 --- Comment #9 from Patrick Palka --- (In reply to Jiang An from comment #8) > This seems a bug, not merely missing of optimization. The string_view obj= ect > should always be statically initialized, because it has static storage > duration and its initializer is a constant iniitializer. Good point. It looks like we're inconsistent about static initialization h= ere -- we do it for suitable copy initialization but not for suitable direct initialization: static std::string_view foo1 =3D {"bar"}; // static initialization static std::string_view foo2("bar"); // dynamic initialization=