From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7460 invoked by alias); 1 Oct 2019 17:26:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 7275 invoked by uid 89); 1 Oct 2019 17:26:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.5 required=5.0 tests=AWL,BAYES_00,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_JMF_BL,SPF_PASS,USER_IN_DEF_SPF_WL autolearn=no version=3.3.1 spammy= X-HELO: mail-oi1-f193.google.com Received: from mail-oi1-f193.google.com (HELO mail-oi1-f193.google.com) (209.85.167.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Oct 2019 17:26:08 +0000 Received: by mail-oi1-f193.google.com with SMTP id k9so15147882oib.7 for ; Tue, 01 Oct 2019 10:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iGV4bdqVwAtrT0TLm1WnOCC7ZiQbBBcstxzHlQovHZw=; b=D4e5dvufJFNR8P+IjECKAcLhtR6xdue92niQa1G4LQyJcV0EC6C8UsxkE1lfipXlFU GhakDbCdkXO3ca1UisJnrm6H3fBNiHadZc52C6djkDIlgE/S0Iowgkz5n29oTEtRnWxx 2s7MgIUG33pikJaenPA2k3RFxVr0BQocTIWChnBuxDfVzLNynA41mlwyN6GvW2o2lBz7 k5ODHY8sBkDfyXn8AA16uC33QUxvnO3/Llf20rnKIVQq7pc3c50khq2M82KdFHCVgDcR sGM4hiASw72XlNjOD41wErAyhtITU80leRhy6KmYcRzlbpGBYsQJvxkCcZU61q5aYh8K IoNg== MIME-Version: 1.0 References: <20190930194621.168116-1-cbiesinger@google.com> <20190930200223.122452-1-cbiesinger@google.com> <87k19o4c5x.fsf@tromey.com> In-Reply-To: <87k19o4c5x.fsf@tromey.com> From: "Christian Biesinger via gdb-patches" Reply-To: Christian Biesinger Date: Tue, 01 Oct 2019 17:26:00 -0000 Message-ID: Subject: Re: [PATCH v4] Change some arguments to gdb::string_view instead of name+len To: Tom Tromey Cc: Christian Biesinger via gdb-patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00021.txt.bz2 On Tue, Oct 1, 2019 at 12:18 PM Tom Tromey wrote: > > >>>>> "Christian" == Christian Biesinger via gdb-patches writes: > > Christian> [This version also replaces an instance of strcmp with string_view's > Christian> operator==, so that the length is correctly respected] > > Thanks. > > Unfortunately I found / remembered another weirdness. > > Christian> - if (linkage_name[len] != '\0') > Christian> + if (linkage_name[linkage_name.length ()] != '\0') > > This code let the caller pass in a possibly-unterminated string, and > then made a local copy with the terminating \0 in that case. > > However, this was always a bad idea, and now is probably a libstdc++ > debug-mode assertion failure (<- just guessing but if it isn't, it > should be!). Well, gdb::string_view (and libstdc++ in g++ 8 and 10) does have this: constexpr const _CharT& operator[](size_type __pos) const { // TODO: Assert to restore in a way compatible with the constexpr. // __glibcxx_assert(__pos < this->_M_len); So I'm going to change it to .data()[]. Sending a new patch in a second. Christian