// 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
using std::type_info;
template<typename _Iterator>
- bool __check_singular(const _Iterator&);
+ _GLIBCXX_CONSTEXPR
+ bool __check_singular(_Iterator const&);
class _Safe_sequence_base;
// 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
__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());
}
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());
}
* 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) \
--- /dev/null
+// 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" }
--- /dev/null
+// 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');
--- /dev/null
+// 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" }
--- /dev/null
+// 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');
--- /dev/null
+// 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" }
--- /dev/null
+// 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" }
--- /dev/null
+// 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');
--- /dev/null
+// 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" }
--- /dev/null
+// 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" }
--- /dev/null
+// 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'" }
--- /dev/null
+// 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'" }
--- /dev/null
+// 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'" }
+
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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'" }
--- /dev/null
+// 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'" }
--- /dev/null
+// 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'" }
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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;
+}