From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 82119 invoked by alias); 13 Jun 2018 20:26:55 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 81714 invoked by uid 89); 13 Jun 2018 20:26:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_NUMSUBJECT,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*f:sk:a0afd6a, H*f:sk:0cae65f, H*f:sk:16a6c14, r261537 X-Spam-User: qpsmtpd, 3 recipients X-HELO: mail-wm0-f65.google.com Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Jun 2018 20:26:47 +0000 Received: by mail-wm0-f65.google.com with SMTP id p11-v6so7773572wmc.4; Wed, 13 Jun 2018 13:26:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=TOUDfp9HODS5NV3TvaipSWvmDF/wsGUFX3k1GTwDEtQ=; b=oDuo2PmC6pR7YrR3jAUBvYDmVpqpt3NlhHm4bRVj7yyQRcw8YJuNfOMt7LgzUGcMQu HpZmAfjgyBxL8f0907JfVD1zPard6Xqy2nnkqe6Z/DCDUoFBCgaGRgYAsDKIOIbK0wSU 6pmAMUESQuXN6In56S+bA7hsCfhQUOVafyZVacHXsSiT1dyQhVwb5YGssGVt1bhR6Tk+ ZWbi7/9CDzV/A0zE3UMIBZr/Fj+BPqCA8dfvajWNWKi3CxhSwPEAGUk7lQSfxouxHPLX JJfWTNiv9T7FIF6ScGi3IncPGTgIeXLJCKSofhSzTzoXpFZPqh6wqxFi2LwR1P109Vqu lgug== X-Gm-Message-State: APt69E10QNh3itNhfFrwxxXUawKU/l2D2Nnaat3sGln+N9w2jwcXHhEq NZDap4YTWl1Q82A+GZ/5ToK9/Pg3 X-Google-Smtp-Source: ADUXVKJP+5X/zDjB4Zr/HnenybHA1GCeiCkKgmlvYoIwhXfrlnYRvzBFov7wghk+2xhmTtwiTj93bA== X-Received: by 2002:a1c:6c0f:: with SMTP id h15-v6mr4183974wmc.30.1528921605137; Wed, 13 Jun 2018 13:26:45 -0700 (PDT) Received: from [192.168.0.22] (arf62-1-82-237-250-248.fbx.proxad.net. [82.237.250.248]) by smtp.googlemail.com with ESMTPSA id z5-v6sm3160288wrh.10.2018.06.13.13.26.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 13:26:44 -0700 (PDT) Subject: Re: libstdc++ bootstrap failure after r261525 To: Jonathan Wakely , Paolo Carlini Cc: Martin Sebor , GCC Mailing List , libstdc++ , gcc-patches References: <0cae65f3-5f7a-b9d9-4e74-8ef17b53248d@gmail.com> <16a6c14b-48e7-4045-3a9a-284e8ce16587@oracle.com> <20180613132415.GU4339@redhat.com> From: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= Message-ID: <2e059936-0c4d-8ebd-8a1c-a927d46b3298@gmail.com> Date: Wed, 13 Jun 2018 22:04:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180613132415.GU4339@redhat.com> Content-Type: multipart/mixed; boundary="------------448C73210020F98866F6BDCD" X-SW-Source: 2018-06/txt/msg00164.txt.bz2 This is a multi-part message in MIME format. --------------448C73210020F98866F6BDCD Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-length: 4027 Here is the missing part of the can_advance patch.     * include/debug/helper_functions.h     (__gnu_debug::_Safe_iterator<>): Add declaration.     (__can_advance(_Ite, _Size)): New.     (__can_advance(const _Safe_iterator<>&, _Size)): Overload declaration.     * include/debug/functions.h     (__gnu_debug::_Safe_iterator<>): Remove declaration.     * include/debug/stl_iterator.h     (__can_advance(const _Safe_iterator<>&)): New definition.     * include/debug/stl_iterator.h     (__can_advance(const std::reverse_iterator<>&, _Size)): New.     (__can_advance(const std::move_iterator<>&, _Size)): New.     * include/debug/macros.h (__glibcxx_check_can_increment): New.     * include/debug/debug.h (__glibcxx_requires_can_increment): New.     * include/bits/stl_algobase.h (fill_n): Use latter.     * testsuite/25_algorithms/fill_n/2.cc: New.     * testsuite/25_algorithms/fill_n/debug/1_neg.cc: New.     * testsuite/25_algorithms/fill_n/debug/2_neg.cc: New.     * testsuite/25_algorithms/fill_n/debug/3_neg.cc: New.     * testsuite/25_algorithms/fill_n/debug/4_neg.cc: New. Tested under linux x86_64, normal and debug modes. Now I understand why applying the patch in the first place failed. François On 13/06/2018 15:24, Jonathan Wakely wrote: > On 13/06/18 13:42 +0200, Paolo Carlini wrote: >> Hi, >> >> On 13/06/2018 08:11, François Dumont wrote: >>> On 12/06/2018 23:26, Martin Sebor wrote: >>>> Bootstrap fails in libstdc++ with the following error. >>>> I haven't investigated it much except to take a peek >>>> at recent libstdc++ commits where r261525 looks like it >>>> introduced __glibcxx_check_can_increment_range, so it >>>> seems like it might have something to do with it.  I don't >>>> see a __glibcxx_requires_can_increment_range macro defined >>>> anywhere in the patch so maybe it's a typo?  Francois, can >>>> you please see what's going on? >>>> >>>> /opt/notnfs/msebor/build/gcc-86114/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:452:45: >>>> error: ‘__glibcxx_requires_can_increment_range’ was not declared in >>>> this scope >>>>        __glibcxx_requires_can_increment_range(__first, __last, >>>> __result); >>>> >>>> Thanks >>>> Martin >>>> . >>>> >>> I had missed the fact that the patch didn't apply correctly on >>> include/debug/debug.h as stated in the ChangeLog entry. >>> >>> It is fixed now. >> But even after r261537 we are seeing the regressions: >> >> FAIL: g++.dg/warn/pr31246.C -std=gnu++11 (test for excess errors) >> FAIL: g++.dg/warn/pr31246.C -std=gnu++14 (test for excess errors) >> FAIL: g++.dg/warn/pr31246.C -std=gnu++98 (test for excess errors) >> >> Which definitely are related. > > And failing Debug Mode tests: > > FAIL: 20_util/hash/84998.cc (test for excess errors) > FAIL: 23_containers/vector/cons/destructible_debug_neg.cc (test for > excess errors) > FAIL: 25_algorithms/binary_search/partitioned.cc (test for excess errors) > FAIL: 25_algorithms/equal_range/partitioned.cc (test for excess errors) > FAIL: 25_algorithms/lexicographical_compare/71545.cc (test for excess > errors) > FAIL: 25_algorithms/lower_bound/partitioned.cc (test for excess errors) > FAIL: 25_algorithms/upper_bound/partitioned.cc (test for excess errors) > FAIL: ext/profile/mutex_extensions_neg.cc (test for excess errors) > > The logs show: > > /home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:452: > error: '__can_advance' is not a member of '__gnu_debug' > /home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:484: > error: '__can_advance' is not a member of '__gnu_debug' > /home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:629: > error: '__can_advance' is not a member of '__gnu_debug' > /home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:664: > error: '__can_advance' is not a member of '__gnu_debug' > > > > --------------448C73210020F98866F6BDCD Content-Type: text/x-patch; name="can_advance.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="can_advance.patch" Content-length: 12658 diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 877f32b..022a3f1 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -783,6 +783,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // concept requirements __glibcxx_function_requires(_OutputIteratorConcept<_OI, _Tp>) + __glibcxx_requires_can_increment(__first, __n); return _OI(std::__fill_n_a(std::__niter_base(__first), __n, __value)); } diff --git a/libstdc++-v3/include/debug/debug.h b/libstdc++-v3/include/debug/debug.h index d055dcb..f157a6d 100644 --- a/libstdc++-v3/include/debug/debug.h +++ b/libstdc++-v3/include/debug/debug.h @@ -62,6 +62,7 @@ namespace __gnu_debug # define __glibcxx_requires_cond(_Cond,_Msg) # define __glibcxx_requires_valid_range(_First,_Last) +# define __glibcxx_requires_can_increment(_First,_Size) # define __glibcxx_requires_can_increment_range(_First1,_Last1,_First2) # define __glibcxx_requires_can_decrement_range(_First1,_Last1,_First2) # define __glibcxx_requires_sorted(_First,_Last) @@ -88,6 +89,8 @@ namespace __gnu_debug # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg) # define __glibcxx_requires_valid_range(_First,_Last) \ __glibcxx_check_valid_range(_First,_Last) +# define __glibcxx_requires_can_increment(_First,_Size) \ + __glibcxx_check_can_increment(_First,_Size) # define __glibcxx_requires_can_increment_range(_First1,_Last1,_First2) \ __glibcxx_check_can_increment_range(_First1,_Last1,_First2) # define __glibcxx_requires_can_decrement_range(_First1,_Last1,_First2) \ diff --git a/libstdc++-v3/include/debug/functions.h b/libstdc++-v3/include/debug/functions.h index 3a2ba74..41519b2 100644 --- a/libstdc++-v3/include/debug/functions.h +++ b/libstdc++-v3/include/debug/functions.h @@ -40,9 +40,6 @@ namespace __gnu_debug { - template - class _Safe_iterator; - template struct _Insert_range_from_self_is_safe { enum { __value = 0 }; }; diff --git a/libstdc++-v3/include/debug/helper_functions.h b/libstdc++-v3/include/debug/helper_functions.h index 94d5016..2073df9 100644 --- a/libstdc++-v3/include/debug/helper_functions.h +++ b/libstdc++-v3/include/debug/helper_functions.h @@ -37,6 +37,9 @@ namespace __gnu_debug { + template + class _Safe_iterator; + /** The precision to which we can calculate the distance between * two iterators. */ @@ -164,6 +167,16 @@ namespace __gnu_debug return __valid_range(__first, __last, __dist); } + // Fallback method, always ok. + template + inline bool + __can_advance(_InputIterator, _Size) + { return true; } + + template + bool + __can_advance(const _Safe_iterator<_Iterator, _Sequence>&, _Size); + #if __cplusplus < 201103L // Helper struct to detect random access safe iterators. template diff --git a/libstdc++-v3/include/debug/macros.h b/libstdc++-v3/include/debug/macros.h index a88faf9..44f48b0 100644 --- a/libstdc++-v3/include/debug/macros.h +++ b/libstdc++-v3/include/debug/macros.h @@ -87,6 +87,13 @@ _GLIBCXX_DEBUG_VERIFY(_First != _Last, \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last)) +// Verify that [_First, _First + _Size) forms a valid range. +#define __glibcxx_check_can_increment(_First,_Size) \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__can_advance(_First, _Size), \ + _M_message(__gnu_debug::__msg_iter_subscript_oob) \ + ._M_iterator(_First, #_First) \ + ._M_integer(_Size, #_Size)) + #define __glibcxx_check_can_increment_range(_First1,_Last1,_First2) \ do \ { \ diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h index 3a53ab7..7ed2b93 100644 --- a/libstdc++-v3/include/debug/safe_iterator.h +++ b/libstdc++-v3/include/debug/safe_iterator.h @@ -862,6 +862,11 @@ namespace __gnu_debug return __res; } + template + inline bool + __can_advance(const _Safe_iterator<_Iterator, _Sequence>& __it, _Size __n) + { return __it._M_can_advance(__n); } + #if __cplusplus < 201103L template struct __is_safe_random_iterator<_Safe_iterator<_Iterator, _Sequence> > diff --git a/libstdc++-v3/include/debug/stl_iterator.h b/libstdc++-v3/include/debug/stl_iterator.h index 21eac76..a6a2a76 100644 --- a/libstdc++-v3/include/debug/stl_iterator.h +++ b/libstdc++-v3/include/debug/stl_iterator.h @@ -47,6 +47,11 @@ namespace __gnu_debug const std::reverse_iterator<_Iterator>& __last) { return __get_distance(__last.base(), __first.base()); } + template + inline bool + __can_advance(const std::reverse_iterator<_Iterator>& __it, _Size __n) + { return __can_advance(__it.base(), -__n); } + #if __cplusplus < 201103L template struct __is_safe_random_iterator > @@ -96,6 +101,11 @@ namespace __gnu_debug const std::move_iterator<_Iterator>& __last) { return __get_distance(__first.base(), __last.base()); } + template + inline bool + __can_advance(const std::move_iterator<_Iterator>& __it, _Size __n) + { return __can_advance(__it.base(), __n); } + template inline auto __unsafe(const std::move_iterator<_Iterator>& __it) diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/2.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/2.cc new file mode 100644 index 0000000..6e18032 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/2.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2018 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.5 [lib.alg.fill] Fill_n. + +// { dg-require-debug-mode "" } + +#include +#include + +#include + +void +test01() +{ + std::vector ref; + ref.push_back(1); + ref.push_back(2); + + std::vector> vvect; + vvect.push_back(std::vector()); + vvect.push_back(std::vector()); + + VERIFY( std::fill_n(vvect.begin(), 2, ref) == vvect.end() ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/debug/1_neg.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/debug/1_neg.cc new file mode 100644 index 0000000..45a88fe --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/debug/1_neg.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2018 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.5 [lib.alg.fill] Fill_n. + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +void +test01() +{ + std::vector vect; + vect.push_back(1); + std::fill_n(vect.begin(), 2, 0); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/debug/2_neg.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/debug/2_neg.cc new file mode 100644 index 0000000..3738ae6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/debug/2_neg.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2018 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.5 [lib.alg.fill] Fill_n. + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +void +test01() +{ + std::vector vect; + vect.push_back(1); + std::fill_n(vect.rbegin(), 2, 0); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/debug/3_neg.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/debug/3_neg.cc new file mode 100644 index 0000000..1497dbb --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/debug/3_neg.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2018 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.5 [lib.alg.fill] Fill_n. + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +void +test01() +{ + std::list l; + l.push_back(1); + std::fill_n(l.begin(), 2, 0); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/debug/4_neg.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/debug/4_neg.cc new file mode 100644 index 0000000..70c4a29 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/debug/4_neg.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2018 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.5 [lib.alg.fill] Fill_n. + +// { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } + +#include +#include + +void +test01() +{ + std::list l; + l.push_back(1); + l.push_back(2); + + std::list::iterator it = l.begin(); + ++it; + std::fill_n(it, 2, 0); +} + +int +main() +{ + test01(); + return 0; +} --------------448C73210020F98866F6BDCD--