[Bug c++/108243] [10/11/12/13 Regression] Missed optimization for static const std::string_view(const char*)

ppalka at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Feb 20 18:33:18 GMT 2023


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

--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Jiang An from comment #8)
> This seems a bug, not merely missing of optimization. The string_view object
> 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 here
--  we do it for suitable copy initialization but not for suitable direct
initialization:

        static std::string_view foo1 = {"bar"}; // static initialization
        static std::string_view foo2("bar");    // dynamic initialization


More information about the Gcc-bugs mailing list