libstdc++: Make _GLIBCXX_DEBUG checks constexpr compatible
libstdc++-v3/ChangeLog: * include/debug/assertions.h (__glibcxx_requires_non_empty_range): Remove __builtin_expect. (__glibcxx_requires_subscript): Likewise. (__glibcxx_requires_nonempty): Likewise. * include/debug/formatter.h (__check_singular): Add C++11 constexpr qualification. * include/debug/helper_functions.h (__check_singular): Likewise. Skip check if constant evaluated. (__valid_range): Do not skip check if constant evaluated. * include/debug/macros.h (_GLIBCXX_DEBUG_VERIFY_COND_AT): Add __builtin_expect. (_GLIBCXX_DEBUG_VERIFY_AT_F): Use __glibcxx_assert_1. * testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc: New test. * testsuite/21_strings/basic_string_view/element_access/char/constexpr.cc: New test. * testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc: New test. * testsuite/21_strings/basic_string_view/element_access/char/front_back_constexpr.cc: New test. * testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc: New test. * testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc: New test. * testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr.cc: New test. * testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc: New test. * testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc: New test. * testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_neg.cc: New test. * testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_pred_neg.cc: New test. * testsuite/25_algorithms/lower_bound/debug/constexpr_valid_range_neg.cc: New test. * testsuite/25_algorithms/lower_bound/debug/partitioned_neg.cc: New test. * testsuite/25_algorithms/lower_bound/debug/partitioned_pred_neg.cc: New test. * testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_neg.cc: New test. * testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_pred_neg.cc: New test. * testsuite/25_algorithms/upper_bound/debug/constexpr_valid_range_neg.cc: New test. * testsuite/25_algorithms/upper_bound/debug/partitioned_neg.cc: New test. * testsuite/25_algorithms/upper_bound/debug/partitioned_pred_neg.cc: New test.
This commit is contained in:
parent
3a5f8d745f
commit
38b17c27ce
23 changed files with 774 additions and 31 deletions
|
@ -45,12 +45,12 @@
|
|||
|
||||
// Verify that [_First, _Last) forms a non-empty iterator range.
|
||||
# define __glibcxx_requires_non_empty_range(_First,_Last) \
|
||||
__glibcxx_assert(__builtin_expect(_First != _Last, true))
|
||||
__glibcxx_assert(_First != _Last)
|
||||
# define __glibcxx_requires_subscript(_N) \
|
||||
__glibcxx_assert(__builtin_expect(_N < this->size(), true))
|
||||
__glibcxx_assert(_N < this->size())
|
||||
// Verify that the container is nonempty
|
||||
# define __glibcxx_requires_nonempty() \
|
||||
__glibcxx_assert(__builtin_expect(!this->empty(), true))
|
||||
__glibcxx_assert(!this->empty())
|
||||
#endif
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
|
|
@ -72,7 +72,8 @@ namespace __gnu_debug
|
|||
using std::type_info;
|
||||
|
||||
template<typename _Iterator>
|
||||
bool __check_singular(const _Iterator&);
|
||||
_GLIBCXX_CONSTEXPR
|
||||
bool __check_singular(_Iterator const&);
|
||||
|
||||
class _Safe_sequence_base;
|
||||
|
||||
|
|
|
@ -120,15 +120,29 @@ namespace __gnu_debug
|
|||
// We may have an iterator that derives from _Safe_iterator_base but isn't
|
||||
// a _Safe_iterator.
|
||||
template<typename _Iterator>
|
||||
_GLIBCXX_CONSTEXPR
|
||||
inline bool
|
||||
__check_singular(_Iterator const& __x)
|
||||
{ return __check_singular_aux(std::__addressof(__x)); }
|
||||
{
|
||||
return
|
||||
#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
|
||||
__builtin_is_constant_evaluated() ? false :
|
||||
#endif
|
||||
__check_singular_aux(std::__addressof(__x));
|
||||
}
|
||||
|
||||
/** Non-NULL pointers are nonsingular. */
|
||||
template<typename _Tp>
|
||||
_GLIBCXX_CONSTEXPR
|
||||
inline bool
|
||||
__check_singular(_Tp* const& __ptr)
|
||||
{ return __ptr == 0; }
|
||||
{
|
||||
return
|
||||
#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
|
||||
__builtin_is_constant_evaluated() ? false :
|
||||
#endif
|
||||
__ptr == 0;
|
||||
}
|
||||
|
||||
/** We say that integral types for a valid range, and defer to other
|
||||
* routines to realize what to do with integral types instead of
|
||||
|
@ -225,11 +239,6 @@ namespace __gnu_debug
|
|||
__valid_range(_InputIterator __first, _InputIterator __last,
|
||||
typename _Distance_traits<_InputIterator>::__type& __dist)
|
||||
{
|
||||
#ifdef __cpp_lib_is_constant_evaluated
|
||||
if (std::is_constant_evaluated())
|
||||
// Detected by the compiler directly.
|
||||
return true;
|
||||
#endif
|
||||
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
|
||||
return __valid_range_aux(__first, __last, __dist, _Integral());
|
||||
}
|
||||
|
@ -253,11 +262,6 @@ namespace __gnu_debug
|
|||
inline bool
|
||||
__valid_range(_InputIterator __first, _InputIterator __last)
|
||||
{
|
||||
#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
|
||||
if (__builtin_is_constant_evaluated())
|
||||
// Detected by the compiler directly.
|
||||
return true;
|
||||
#endif
|
||||
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
|
||||
return __valid_range_aux(__first, __last, _Integral());
|
||||
}
|
||||
|
|
|
@ -38,25 +38,15 @@
|
|||
* the user error and where the error is reported.
|
||||
*
|
||||
*/
|
||||
#if 0 /* defined _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED */
|
||||
# define _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func) \
|
||||
if (__builtin_is_constant_evaluated()) \
|
||||
/* FIXME: Compilation error here when !_Cond. */ \
|
||||
break; \
|
||||
if (! (_Cond)) \
|
||||
#define _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func) \
|
||||
if (__builtin_expect(!bool(_Cond), false)) \
|
||||
__gnu_debug::_Error_formatter::_S_at(_File, _Line, _Func) \
|
||||
._ErrMsg._M_error()
|
||||
#else
|
||||
# define _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func) \
|
||||
if (! (_Cond)) \
|
||||
__gnu_debug::_Error_formatter::_S_at(_File, _Line, _Func) \
|
||||
._ErrMsg._M_error()
|
||||
#endif
|
||||
|
||||
#define _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond,_ErrMsg,_File,_Line,_Func) \
|
||||
do \
|
||||
{ \
|
||||
_GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func); \
|
||||
do { \
|
||||
__glibcxx_assert_1(_Cond) \
|
||||
{ _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func); } \
|
||||
} while (false)
|
||||
|
||||
#define _GLIBCXX_DEBUG_VERIFY_AT(_Cond,_ErrMsg,_File,_Line) \
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++17 -D_GLIBCXX_ASSERTIONS" }
|
||||
// { dg-do compile { target c++17 xfail *-*-* } }
|
||||
|
||||
#include <string_view>
|
||||
|
||||
typedef std::string_view string_view_type;
|
||||
|
||||
constexpr char
|
||||
back()
|
||||
{
|
||||
string_view_type s("");
|
||||
return s.back();
|
||||
}
|
||||
|
||||
static_assert(back() != 'a'); // { dg-error "non-constant condition" }
|
||||
|
||||
// { dg-prune-output "in 'constexpr' expansion" }
|
||||
// { dg-prune-output "failed_assertion" }
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++17" }
|
||||
// { dg-do compile { target c++17 } }
|
||||
|
||||
#include <string_view>
|
||||
|
||||
constexpr char
|
||||
test()
|
||||
{
|
||||
typedef std::string_view string_view_type;
|
||||
string_view_type s("abcd");
|
||||
return s[0];
|
||||
}
|
||||
|
||||
static_assert(test() == 'a');
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++17 -D_GLIBCXX_ASSERTIONS" }
|
||||
// { dg-do compile { target c++17 xfail *-*-* } }
|
||||
|
||||
#include <string_view>
|
||||
|
||||
constexpr char
|
||||
test()
|
||||
{
|
||||
typedef std::string_view string_view_type;
|
||||
string_view_type s("abcd");
|
||||
return s[s.length()];
|
||||
}
|
||||
|
||||
static_assert(test() == 0); // { dg-error "non-constant condition" }
|
||||
|
||||
// { dg-prune-output "in 'constexpr' expansion" }
|
||||
// { dg-prune-output "failed_assertion" }
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++17" }
|
||||
// { dg-do compile { target c++17 } }
|
||||
|
||||
#include <string_view>
|
||||
|
||||
typedef std::string_view string_view_type;
|
||||
|
||||
constexpr char
|
||||
front()
|
||||
{
|
||||
string_view_type s("abcd");
|
||||
return s.front();
|
||||
}
|
||||
|
||||
static_assert(front() == 'a');
|
||||
|
||||
constexpr char
|
||||
back()
|
||||
{
|
||||
string_view_type s("abcd");
|
||||
return s.back();
|
||||
}
|
||||
|
||||
static_assert(back() == 'd');
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++17 -D_GLIBCXX_ASSERTIONS" }
|
||||
// { dg-do compile { target c++17 xfail *-*-* } }
|
||||
|
||||
#include <string_view>
|
||||
|
||||
typedef std::string_view string_view_type;
|
||||
|
||||
constexpr char
|
||||
front()
|
||||
{
|
||||
string_view_type s("");
|
||||
return s.front();
|
||||
}
|
||||
|
||||
static_assert(front() != 'a'); // { dg-error "non-constant condition" }
|
||||
|
||||
// { dg-prune-output "in 'constexpr' expansion" }
|
||||
// { dg-prune-output "failed_assertion" }
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++17 -D_GLIBCXX_ASSERTIONS" }
|
||||
// { dg-do compile { target c++17 xfail *-*-* } }
|
||||
|
||||
#include <string_view>
|
||||
|
||||
typedef std::wstring_view string_view_type;
|
||||
|
||||
constexpr wchar_t
|
||||
back()
|
||||
{
|
||||
string_view_type s(L"");
|
||||
return s.back();
|
||||
}
|
||||
|
||||
static_assert(back() != L'a'); // { dg-error "non-constant condition" }
|
||||
|
||||
// { dg-prune-output "in 'constexpr' expansion" }
|
||||
// { dg-prune-output "failed_assertion" }
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++17" }
|
||||
// { dg-do compile { target c++17 } }
|
||||
|
||||
#include <string_view>
|
||||
|
||||
constexpr wchar_t
|
||||
test()
|
||||
{
|
||||
typedef std::wstring_view string_view_type;
|
||||
string_view_type s(L"abcd");
|
||||
return s[0];
|
||||
}
|
||||
|
||||
static_assert(test() == L'a');
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++17 -D_GLIBCXX_ASSERTIONS" }
|
||||
// { dg-do compile { target c++17 xfail *-*-* } }
|
||||
|
||||
#include <string_view>
|
||||
|
||||
constexpr wchar_t
|
||||
test()
|
||||
{
|
||||
typedef std::wstring_view string_view_type;
|
||||
string_view_type s(L"abcd");
|
||||
return s[4];
|
||||
}
|
||||
|
||||
static_assert(test() == 0); // { dg-error "non-constant condition" }
|
||||
|
||||
// { dg-prune-output "in 'constexpr' expansion" }
|
||||
// { dg-prune-output "failed_assertion" }
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++17 -D_GLIBCXX_ASSERTIONS" }
|
||||
// { dg-do compile { target c++17 xfail *-*-* } }
|
||||
|
||||
#include <string_view>
|
||||
|
||||
typedef std::wstring_view string_view_type;
|
||||
|
||||
constexpr wchar_t
|
||||
front()
|
||||
{
|
||||
string_view_type s(L"");
|
||||
return s.front();
|
||||
}
|
||||
|
||||
static_assert(front() != L'a'); // { dg-error "non-constant condition" }
|
||||
|
||||
// { dg-prune-output "in 'constexpr' expansion" }
|
||||
// { dg-prune-output "failed_assertion" }
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++2a" }
|
||||
// { dg-do compile { target c++2a xfail *-*-* } }
|
||||
// { dg-require-debug-mode { } }
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
struct A
|
||||
{
|
||||
int _i;
|
||||
|
||||
constexpr bool
|
||||
operator<(const A& a) const
|
||||
{ return _i < a._i; }
|
||||
};
|
||||
|
||||
constexpr bool
|
||||
test()
|
||||
{
|
||||
constexpr std::array<A, 12> ca0{{0, 1, 2, 3, 4, 5, 6, 5, 8, 9, 10, 11}};
|
||||
|
||||
constexpr A a6{ 6 };
|
||||
const auto it = std::lower_bound(ca0.begin(), ca0.end(), a6);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static_assert(test()); // { dg-error "" }
|
||||
|
||||
// { dg-prune-output "failed_assertion" }
|
||||
// { dg-prune-output "in 'constexpr'" }
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++2a" }
|
||||
// { dg-do compile { target c++2a xfail *-*-* } }
|
||||
// { dg-require-debug-mode { } }
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
constexpr bool
|
||||
test()
|
||||
{
|
||||
constexpr std::array<int, 12> ca0{{0, 1, 2, 3, 4, 5, 6, 5, 8, 9, 10, 11}};
|
||||
|
||||
const auto it = std::lower_bound(ca0.begin(), ca0.end(), 6, std::less<int>());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static_assert(test()); // { dg-error "" }
|
||||
|
||||
// { dg-prune-output "failed_assertion" }
|
||||
// { dg-prune-output "in 'constexpr'" }
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++2a" }
|
||||
// { dg-do compile { target c++2a xfail *-*-* } }
|
||||
// { dg-require-debug-mode { } }
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
constexpr bool
|
||||
test1()
|
||||
{
|
||||
constexpr std::array<int, 12> ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
|
||||
|
||||
const auto outbb = std::lower_bound(ca0.end(), ca0.begin(), 6);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static_assert(test1()); // { dg-error "" }
|
||||
|
||||
constexpr bool
|
||||
test2()
|
||||
{
|
||||
constexpr std::array<int, 12> ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
|
||||
|
||||
const auto outcc = std::lower_bound(ca0.end(), ca0.begin(), 6,
|
||||
std::less<int>());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static_assert(test2()); // { dg-error "" }
|
||||
|
||||
// { dg-prune-output "failed_assertion" }
|
||||
// { dg-prune-output "in 'constexpr'" }
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do run { xfail *-*-* } }
|
||||
// { dg-require-debug-mode "" }
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
struct A
|
||||
{
|
||||
A(int i) : _i(i)
|
||||
{ }
|
||||
|
||||
int _i;
|
||||
|
||||
bool
|
||||
operator<(const A& a) const
|
||||
{ return _i < a._i; }
|
||||
};
|
||||
|
||||
void test01()
|
||||
{
|
||||
A as[] = { 0, 1, 2, 0, 2, 3 };
|
||||
std::lower_bound(as, as + 6, A(1));
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do run { xfail *-*-* } }
|
||||
// { dg-require-debug-mode "" }
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
void test01()
|
||||
{
|
||||
int as[] = { 0, 1, 0, 2, 3 };
|
||||
std::lower_bound(as, as + 5, 1, std::less<int>());
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++2a" }
|
||||
// { dg-do compile { target c++2a xfail *-*-* } }
|
||||
// { dg-require-debug-mode { } }
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
struct A
|
||||
{
|
||||
int _i;
|
||||
|
||||
constexpr bool
|
||||
operator<(const A& a) const
|
||||
{ return _i == a._i; }
|
||||
};
|
||||
|
||||
constexpr bool
|
||||
test()
|
||||
{
|
||||
constexpr std::array<A, 12> ca0{{0, 1, 2, 3, 4, 5, 6, 5, 8, 9, 10, 11}};
|
||||
|
||||
constexpr A a6{ 6 };
|
||||
const auto it = std::upper_bound(ca0.begin(), ca0.end(), a6);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static_assert(test()); // { dg-error "" }
|
||||
|
||||
// { dg-prune-output "failed_assertion" }
|
||||
// { dg-prune-output "in 'constexpr'" }
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++2a" }
|
||||
// { dg-do compile { target c++2a xfail *-*-* } }
|
||||
// { dg-require-debug-mode { } }
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
constexpr bool
|
||||
test()
|
||||
{
|
||||
constexpr std::array<int, 12> ca0{{0, 1, 2, 3, 4, 5, 7, 6, 8, 9, 10, 11}};
|
||||
|
||||
const auto it = std::upper_bound(ca0.begin(), ca0.end(), 6, std::less<int>());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static_assert(test()); // { dg-error "" }
|
||||
|
||||
// { dg-prune-output "failed_assertion" }
|
||||
// { dg-prune-output "in 'constexpr'" }
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++2a" }
|
||||
// { dg-do compile { target c++2a xfail *-*-* } }
|
||||
// { dg-require-debug-mode { } }
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
constexpr bool
|
||||
test1()
|
||||
{
|
||||
constexpr std::array<int, 12> ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
|
||||
|
||||
const auto outbb = std::upper_bound(ca0.end(), ca0.begin(), 6);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static_assert(test1()); // { dg-error "" }
|
||||
|
||||
constexpr bool
|
||||
test2()
|
||||
{
|
||||
constexpr std::array<int, 12> ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
|
||||
|
||||
const auto outcc = std::upper_bound(ca0.end(), ca0.begin(), 6,
|
||||
std::less<int>());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static_assert(test2()); // { dg-error "" }
|
||||
|
||||
// { dg-prune-output "failed_assertion" }
|
||||
// { dg-prune-output "in 'constexpr'" }
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do run { xfail *-*-* } }
|
||||
// { dg-require-debug-mode "" }
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
struct A
|
||||
{
|
||||
A(int i) : _i(i)
|
||||
{ }
|
||||
|
||||
int _i;
|
||||
|
||||
bool
|
||||
operator<(const A& a) const
|
||||
{ return _i < a._i; }
|
||||
};
|
||||
|
||||
void test01()
|
||||
{
|
||||
A as[] = { 0, 2, 1, 3, 4, 5 };
|
||||
std::upper_bound(as, as + 6, A(1));
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2020 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
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do run { xfail *-*-* } }
|
||||
// { dg-require-debug-mode "" }
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
void test01()
|
||||
{
|
||||
int as[] = { 0, 2, 1, 3, 4 };
|
||||
std::upper_bound(as, as + 5, 1, std::less<int>());
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue