From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by sourceware.org (Postfix) with ESMTPS id E30533858D20 for ; Mon, 11 Mar 2024 20:07:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E30533858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E30533858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::235 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710187642; cv=none; b=Ho8E0KwK6uYlueDeJVDFMX9CQOBC6ZYRqgUnfJLMSxjPQvQdGSt4Nu1L0UN5GIFX+y4avPTF0dLniJx80CR3+pxGS6uWX83k3GXY5wOmfWg+90r/XndA4Pe8J164Q2sGzAOfQl3hLlnjBc8+nAzDP8QSIgKE2BYWT5BAV67mo0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710187642; c=relaxed/simple; bh=dXHRFabR7s3Em8LatX7SWgVmMSenzFNaSVYeIhqrbwY=; h=DKIM-Signature:From:Mime-Version:Subject:Message-Id:Date:To; b=ELiJwATVAyJImNQXFFjqq9xvfTsWlF12eZJw5s1k2ikIT1O7AAKwtG24x6jisss6UZGexloAO4R/QKj6Jp5X1ezaTCp/PWPPkxXRwW0BWJzDPx50IfADxtjP8r02ec+35k7e3n4sciKVhuUnd4SFRisEvuhMoJLMiNBwwin+BPk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2d208be133bso52255861fa.2 for ; Mon, 11 Mar 2024 13:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710187639; x=1710792439; darn=gcc.gnu.org; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:from:to:cc:subject:date:message-id:reply-to; bh=Ln936HnredWB6SotUgzfPVsh3quBS75CN1818X4wn+A=; b=VmV90tfqlpfQjjDaukQZqx96SpedAfQVB7p1y+U6M4P7DaExioDmZFuB8QCfNBVz+9 iPueElVEIzf8qYWLZRt8mRvMLuIcBOL4Wcc6OO8lJULygCUcOFVsbRMCkgr/N0hQkJS4 zYOZPWq4DXm54MQunaj1N1aG+CEBmHmMCL/2F2kW224Xm8pkMlXSL4WIwAWonYaYJ6Sz uh4JYvSoUCRj1PQOiw0hpWnSjnHX4t89wmWi3c9uasLPHK004Vj/LCpJsk4bINe17f3D B7rXPSXBt0DGq+PxBbIsMxaJ8Ugsxauqe8ewKP6EPzUEvhCIvKkBrX55zYgU1cq0Qz3G ovYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710187639; x=1710792439; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ln936HnredWB6SotUgzfPVsh3quBS75CN1818X4wn+A=; b=WqyArLbOPGyuiWVQToYv64B50Qtb6CF1EIctEgIs1y3WPlMD/iZF87mTkyCNbQgh/L pSf9/9IBkzmOBAkCeEpzXN9NdU901FqUKO1lqQ8GrAJ37Lrk5C6uM20GX1Fr8GdRs3l2 RHYMVUHom1YeXhVUohGiNwQfTnGeoAiNOSXLzIYBYBpk/sDZWRIe/BM0MkomV5WYWxLp 8OdV6O1DxOiDucsMNLt4YcX70J/Y3QoBXM4nvcHPNcdlNgoEBfTbRMXV0jHGo0YxyTSJ WloO7Is1DQT4efhfmcUy90JmQxvVuS91rJoWWB/3TZI8fJNZmTkH0eYjSaP/AtIDM+eT iQrQ== X-Gm-Message-State: AOJu0YyBHjAAZIqrwjS3slliycSX+FRV4gPae2Zl6gtzsdfSnz/fvPWD cQ1fHG47lPAPrJf8H2FjPxazw+lrKBoEBBliYATYAYKUDMFI5kye+mtqrStl X-Google-Smtp-Source: AGHT+IENFzjvomtXOcMwPvP0p461M83f/iLA0KRZRjVu3vybKi0OgEyYGp92zJFQTMv/DmyAxiHIug== X-Received: by 2002:a2e:2407:0:b0:2d3:4ff3:963f with SMTP id k7-20020a2e2407000000b002d34ff3963fmr4691718ljk.10.1710187638847; Mon, 11 Mar 2024 13:07:18 -0700 (PDT) Received: from smtpclient.apple (89-74-210-109.dynamic.chello.pl. [89.74.210.109]) by smtp.gmail.com with ESMTPSA id w23-20020a2ea3d7000000b002d0d02e50fdsm1288266lje.78.2024.03.11.13.07.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2024 13:07:18 -0700 (PDT) From: Maciej Miera Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.4\)) Subject: _LIBCXX_DEBUG value initialized singular iterators assert failures in std algorithms Message-Id: <73AC0523-2237-46FD-9885-7AE3F8663DF2@gmail.com> Date: Mon, 11 Mar 2024 21:07:16 +0100 To: libstdc++@gcc.gnu.org X-Mailer: Apple Mail (2.3696.120.41.1.4) X-Spam-Status: No, score=2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hello, I have tried to introduce an extra level of safety to my codebase and = utilize _GLIBCXX_DEBUG in my test builds in order to catch faulty = iterators. However, I have encountered the following problem: I would like to = utilize singular, value-initialized iterators as an arbitrary "null = range=E2=80=9D. However, this leads to failed assertions in std:: algorithms taking such = range. Consider the following code sample with find_if: #include #include #include #ifndef __cpp_lib_null_iterators #warning "Not standard compliant" #endif int main() { std::multimap::iterator it1{}; std::multimap::iterator it2{}; (void) (it1=3D=3Dit2); // OK (void) std::find_if( it1, it2, [](const auto& el) { return el.second =3D=3D 8;}); } Compiled with -std=3Dc++20 and -D_GLIBCXX_DEBUG it produces the warning = "Not standard compliant" and the execution results in the following assert failure: = /opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/stl_algo.h:3875:= In function: constexpr _IIter std::find_if(_IIter, _IIter, _Predicate) [with = _IIter =3D=20 gnu_debug::_Safe_iterator<_Rb_tree_iterator >,=20= debug::multimap, bidirectional_iterator_tag>; _Predicate = =3D=20 main()::] The question is though: is it by design, or is it just a mere oversight? = The warning actually suggest the first option. If it is an intentional design choice, could you provide some rationale = behind it, please? Compiler explorer link with demo below: https://godbolt.org/z/e8xa5Eoqn Best regards, A M. Miera=