From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 58940385AE44 for ; Fri, 24 Jun 2022 09:35:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 58940385AE44 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-461-zzF_mpT2NXGn2nU_dSem0w-1; Fri, 24 Jun 2022 05:35:15 -0400 X-MC-Unique: zzF_mpT2NXGn2nU_dSem0w-1 Received: by mail-ed1-f72.google.com with SMTP id o11-20020a056402438b00b0043676efd75dso1406140edc.16 for ; Fri, 24 Jun 2022 02:35:15 -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:from:date :message-id:subject:to:cc; bh=WC14FJJhFYDQpmloa8BOOf8FRfjdcLeGyLe4cOjqdAA=; b=6+DutXymyzrjZ3MbcsEr2nFrXaSvEaOjX4ZLRbwxYYDiRALaa97dAojqhcd1KRPNHh T3fmQAQWGLRBcuoo8qjomPB5g6nk1Z41m4Z6DusLaxyk9Zjbl/mz9WjL07Wi65V+oyTB 9br/bqrc/bI+lxXJPvkEHaczJGOO8/qmgFG46DGcNKkeNSeinnDo2NbzGNRaXMRQmYzp 14AGMwuI2M5mwl4j1V2aY9XMUQ1G23Cbmgg5jJ5obt3D9rM8uXLld+74rRwdHLCko8Om QV76YlPY9ldtlYlr5qo7Yt7SoD7XtZrrbDZ36sGJ7yWeBx6ckY7yMf7DCCQ5MLQ1TMzr mkww== X-Gm-Message-State: AJIora/10uwG/beZoLbHrKpgDxzoJRM6Xb6u6hZ5JzH1KTx0zTdjoe/y JchBtgPU/6r9D39c7mNWlIaL0AuH+S/SiiYVaJvnSqBDrHFdZAphWAWox3/Vp2HE+Pu1On3v66v NAJqBwM6BQ8SCEbvLTsHIx8T3V3u06SE= X-Received: by 2002:a05:6402:3298:b0:435:8145:e6db with SMTP id f24-20020a056402329800b004358145e6dbmr16337854eda.294.1656063314645; Fri, 24 Jun 2022 02:35:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tNfQMoo1bbPf/8vHN8TXe6nDwQaeVQ7gvExBda9KuEd1hvbB6I6R2FwAArYrZSwqZqbPRsQTIwhP/RDNqyUps= X-Received: by 2002:a05:6402:3298:b0:435:8145:e6db with SMTP id f24-20020a056402329800b004358145e6dbmr16337836eda.294.1656063314469; Fri, 24 Jun 2022 02:35:14 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Fri, 24 Jun 2022 10:35:03 +0100 Message-ID: Subject: Re: string::iterator should have more error checking To: cauldwell.thomas@gmail.com Cc: "libstdc++" X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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 09:35:18 -0000 On Fri, 24 Jun 2022 at 10:06, Frederick Virchanza Gotham wrote: > > On Thu, Jun 23, 2022 at 11:36 PM Jonathan Wakely wrote: > > > Yes it does: > > https://godbolt.org/z/hYhcfjTWY > > > You're right, that does work. > > I've put together another little sample program. The dereferencing of > an "end()" iterator is flagged by __gnu_debug::_Safe_iterator, however > the invalid memory access on the last line -- strangely -- is not > noticed by "-fsanitize" > > https://godbolt.org/z/4nzjGG8o3 That's expected. The contents of the string_view are a string literal, which is in the program image, not on the heap. AddressSanitizer doesn't check access to such memory. The byte after the string literal "brush" is uninitialized, but it does exist in a valid memory page. And it's not detected by Debug Mode because string_view iterators are just pointers.