From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id 63DA13850239 for ; Fri, 24 Jun 2022 11:14:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 63DA13850239 Received: by mail-ej1-x631.google.com with SMTP id pk21so4044625ejb.2 for ; Fri, 24 Jun 2022 04:14:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=JvMV9kPWFXoFGorJQO7byjyd1bYoRuvtjPWttnu1mqA=; b=GawttgUQQeyOWNnhcWRqxXj7VDa/kPy8mfy9hCb/LfLg+35jtdhb3f+Lo6fCwhETMr wjDnF1sLv07qujhymuqpvWdhiFWVwsjXg3S4uhUBEBJjpiJyJ3Q0xUZ1fBbk/Kqo4wj4 vPMkfvS3yMDYHsc0Y0ahnoBJqRCBr+VHF+hvTqid1LkSHtAz0UtZGI7Anns0aJnl47EI fr1kV15/J3RPXXt5OBlg7NXkxEW2Si8K/DW3l5iEzd3GMg7BjxckLKSgB7AkgxgM+4NN ZWUV5Nw7cTvlHEEV9DZdzIz5l23S+urK5DYsqI0YOzBu3K8zZAoVrzYxTwuv09M9gCQm NXZA== X-Gm-Message-State: AJIora9LMhlutHseb/OpsNFnfBaxvZXpg8Ic2g2FkEj/X+JtDj9q1PLW OLLaFTP9gQMKe7rwXk+DyckPebiXGLU8Cj5RhQM= X-Google-Smtp-Source: AGRyM1vD6LIuC1MZtxXrTwmPxhpUg+Dc1ZWdz1FUgpIJJiRwW8EKWzYuVcj48egCDXz7bSOr2cM7Q3mTFSuDf5ZiNAs= X-Received: by 2002:a17:907:980f:b0:721:edd3:7d61 with SMTP id ji15-20020a170907980f00b00721edd37d61mr13038078ejc.13.1656069270186; Fri, 24 Jun 2022 04:14:30 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Reply-To: cauldwell.thomas@gmail.com From: Frederick Virchanza Gotham Date: Fri, 24 Jun 2022 12:14:19 +0100 Message-ID: Subject: Re: string::iterator should have more error checking To: Jonathan Wakely Cc: "libstdc++" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jun 2022 11:14:32 -0000 On Fri, Jun 24, 2022 at 11:28 AM Jonathan Wakely wrote: > But &*(s2.cend() + 1u) accesses the byte after the null, doesn't it? It dereferences a pointer to the byte after the null, certainly, but there isn't actually any reading/writing of the byte after the null. I'm pretty sure that's why "-fsanitize" doesn't notice a problem. However . . . check out the following: https://godbolt.org/z/jPcv9M6e3 Strangely it doesn't mind printing an invalid "uintptr_t", but it does mind printing an invalid pointer. > I don't think that extra check is appropriate though. As you say, it's > entirely valid according to the standard, so if your application wants > to disallow that, checking for it belongs in your application. Yeah maybe I should inherit from string_view.