From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6A8363858D32; Thu, 2 Nov 2023 17:40:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A8363858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698946852; bh=sHYL2ZYtqgvJjDzcr2FGHpQsq1tkJMjYK/dqeQm2wUo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TUkqI+1ui2rpxL1N5zn2Za2+Hz55GT+v4QtHWgQdTC7tTJKz6Sx7ARh+DFurxb9+W szfMDhSIWArXZ6dU0gnP8d7EoevNOc6fRAH+oRbWkZ1ncXRso6DY3PJdhJ75rpp9Ov 2EF9getTCJ3svFGF1ShBy3zXdJJ9mMs56Aag4ijk= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/112314] Missing index assertions in basic_string_view Date: Thu, 02 Nov 2023 17:40:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.3.0 X-Bugzilla-Keywords: 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: 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=3D112314 --- Comment #7 from Jonathan Wakely --- (In reply to Jose Dapena Paz from comment #5) > - The length is less than the possible pointer difference (checked with > numeric_limits). That seems too lenient to me, because for wchar_t, char16_t and char32_t the maximum length that can actually exist in the program will be less than PTRDIFF_MAX. Our std::vector::max_size() uses this: // std::distance(begin(), end()) cannot be greater than PTRDIFF_MAX, // and realistically we can't store more than PTRDIFF_MAX/sizeof(T) // (even if std::allocator_traits::max_size says we can). const size_t __diffmax =3D __gnu_cxx::__numeric_traits::__max / sizeof(_Tp);=