From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2786D385B805; Tue, 13 Sep 2022 14:48:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2786D385B805 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663080511; bh=q8cztUtGEctVEErRrZlWiCNXCUG/ZoiFHXQDoA+jwNk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=X1Pxoa0rr54TcyiBUxbUEpujnWsskxgDr/LkQc21rL42ZnOIxRbkUy6DcKk57MxjN k05eG2WABu0B6cXXipYjmCgUiwQppQODoSCk6J7zWeyDBXNGrOsATMaKqNz2axDoXt qR9plqGAurDdDizbi7cEl9R9sl9TnFxjlHcCzcGQ= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106926] string_view construction from literal string containing null/zero should warn Date: Tue, 13 Sep 2022 14:48:30 +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: 13.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW 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: keywords blocked cf_reconfirmed_on bug_status everconfirmed bug_severity 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=3D106926 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic Blocks| |87403 Last reconfirmed| |2022-09-13 Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Severity|normal |enhancement --- Comment #1 from Jonathan Wakely --- Is this a real problem you've seen in the wild? The same argument applies to std::string, doesn't it? To generalise it, I think we would probably want a new attribute telling the compiler that a character pointer argument will be passed to strlen, and on= ly that many bytes used (i.e. it's treated as a "null-terminated byte string" = in ISO C++ terminology). Then the compiler can warn if an argument to that function has unreachable characters. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D87403 [Bug 87403] [Meta-bug] Issues that suggest a new warning=