From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 0A156385700F; Sun, 18 Apr 2021 14:04:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0A156385700F Received: by mail-wm1-x32e.google.com with SMTP id w186so12225422wmg.3; Sun, 18 Apr 2021 07:04:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mgsg7a16uUMMydv3K76XqHAii2qNMgICqWzbmoB4hXw=; b=AYF+1vKYPbLVkjhqN8EsvQ2deA0D1lEe5FXCTR3Ma1Hxlbbzon2NLpKlNe0QCucYzG iWKDpgpNKA+RWePQCqAOG/bN0XopbAini3syJJcE4uZC5ZHHIJqJcbvlDtCtOytOlFjJ jS3UB1zKyVPbhwGj62IL9GoHCLfLme4qKy2FhJjYUm+QcEU8iQnmv9MQWCFoCM9Asyg5 h1zlK/7uBz3HzCzeWNEesfqS/+9P2eNf9H/x5iqScO0yAvuMGzeh6Bn6sbVVGj1olGre ZLi0e51fxUE+f3QA9nITevlpBN7c6Nb80fb0M8A5kbyLayDAyyZYuQeMsCgg6LdvxBnt ui+g== X-Gm-Message-State: AOAM530+rGircIQPzG5EWBU2g0w+mXlZiT4YKjbiy7InglxE31KewwsK vXyQ1ssfHJX+fXe4CPOVK0ycSNf+8Qdls5ivDLM= X-Google-Smtp-Source: ABdhPJxI3f+2apcFYdvCP5Q2m/zVkCF5hAOlNhXBBzvhZ+T3HVXEbsEQ3gLVQK5m1Chn7iuDdn4LyDjSjPW6vF2AtOk= X-Received: by 2002:a1c:b342:: with SMTP id c63mr17193098wmf.162.1618754663161; Sun, 18 Apr 2021 07:04:23 -0700 (PDT) MIME-Version: 1.0 References: <70f13ddf-8b3a-1a6b-006f-21a9cb3a5db9@gmail.com> In-Reply-To: <70f13ddf-8b3a-1a6b-006f-21a9cb3a5db9@gmail.com> From: Jonathan Wakely Date: Sun, 18 Apr 2021 15:04:12 +0100 Message-ID: Subject: Re: [Bug libstdc++/99402] [10 Regression] std::copy creates _GLIBCXX_DEBUG false positive for attempt to subscript a dereferenceable (start-of-sequence) iterator To: =?UTF-8?Q?Fran=C3=A7ois_Dumont?= Cc: "libstdc++" , gcc-patches X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Sun, 18 Apr 2021 14:04:34 -0000 On Sun, 18 Apr 2021, 15:01 Fran=C3=A7ois Dumont via Libstdc++, < libstdc++@gcc.gnu.org> wrote: > Hi > > Ok to backport this to gcc-10 branch ? > Yes please, thanks. > Tested under Linux x86_64. > > Fran=C3=A7ois > > > On 13/04/21 10:51 pm, redi at gcc dot gnu.org wrote: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99402 > > > > Jonathan Wakely changed: > > > > What |Removed |Added > > > -------------------------------------------------------------------------= --- > > Summary|[10/11 Regression] |[10 Regression] > std::copy > > |std::copy creates |creates _GLIBCXX_DEBU= G > > |_GLIBCXX_DEBUG false |false positive for > attempt > > |positive for attempt to |to subscript a > > |subscript a dereferenceable |dereferenceable > > |(start-of-sequence) |(start-of-sequence) > > |iterator |iterator > > > > --- Comment #10 from Jonathan Wakely --- > > This was fixed on trunk by r11-8100: > > > > libstdc++: [_GLIBCXX_DEBUG] Fix management of __dp_sign_max_size [PR > 99402] > > > > __dp_sign precision indicates that we found out what iterator comes > first or > > last in the range. __dp_sign_max_size is the same plus it gives the > information > > of the max size of the range that is to say the max_size value such tha= t > > distance(lhs, rhs) < max_size. > > Thanks to this additional information we are able to tell when a copy o= f > n > > elements > > to that range will fail even if we do not know exactly how large it is. > > > > This patch makes sure that we are properly using this information. > > > > libstdc++-v3/ChangeLog: > > > > PR libstdc++/99402 > > * include/debug/helper_functions.h > (__can_advance(_InputIterator, > > const std::pair<_Diff, _Distance_precision>&, int)): New. > > (__can_advance(const _Safe_iterator<>&, > > const std::pair<_Diff, _Distance_precision>&, int)): New. > > * include/debug/macros.h (__glibcxx_check_can_increment_dist): > New, > > use latter. > > (__glibcxx_check_can_increment_range): Adapt to use latter. > > (__glibcxx_check_can_decrement_range): Likewise. > > * include/debug/safe_iterator.h > > (_Safe_iterator<>::_M_can_advance(const std::pair<_Diff, > > _Distance_precision>&, > > int)): New. > > (__can_advance(const _Safe_iterator<>&, > > const std::pair<_Diff, _Distance_precision>&, int)): New. > > * include/debug/safe_iterator.tcc > > (_Safe_iterator<>::_M_can_advance(const std::pair<_Diff, > > _Distance_precision>&, > > int)): New. > > (_Safe_iterator<>::_M_valid_range(const _Safe_iterator<>&, > > std::pair&, bool)): Adap= t > for > > __dp_sign_max_size. > > (__copy_move_a): Adapt to use > __glibcxx_check_can_increment_dist. > > (__copy_move_backward_a): Likewise. > > (__equal_aux): Likewise. > > * include/debug/stl_iterator.h (__can_advance(const > > std::reverse_iterator<>&, > > const std::pair<_Diff, _Distance_precision>&, int)): New. > > (__can_advance(const std::move_iterator<>&, > > const std::pair<_Diff, _Distance_precision>&, int)): New. > > * testsuite/25_algorithms/copy/debug/99402.cc: New test. > > > >