return __builtin_is_constant_evaluated();
#else
size_t __i = 0;
- while (__builtin_constant_p(__a[__i]) && __i < __n)
+ while (__i < __n && __builtin_constant_p(__a[__i]))
__i++;
return __i == __n;
#endif
static _GLIBCXX17_CONSTEXPR int
compare(const char_type* __s1, const char_type* __s2, size_t __n)
{
+ if (__n == 0)
+ return 0;
#if __cplusplus >= 201703L
if (__builtin_constant_p(__n)
&& __constant_char_array_p(__s1, __n)
&& __constant_char_array_p(__s2, __n))
return __gnu_cxx::char_traits<char_type>::compare(__s1, __s2, __n);
#endif
- if (__n == 0)
- return 0;
return __builtin_memcmp(__s1, __s2, __n);
}
static _GLIBCXX17_CONSTEXPR const char_type*
find(const char_type* __s, size_t __n, const char_type& __a)
{
+ if (__n == 0)
+ return 0;
#if __cplusplus >= 201703L
if (__builtin_constant_p(__n)
&& __builtin_constant_p(__a)
&& __constant_char_array_p(__s, __n))
return __gnu_cxx::char_traits<char_type>::find(__s, __n, __a);
#endif
- if (__n == 0)
- return 0;
return static_cast<const char_type*>(__builtin_memchr(__s, __a, __n));
}
static _GLIBCXX17_CONSTEXPR int
compare(const char_type* __s1, const char_type* __s2, size_t __n)
{
+ if (__n == 0)
+ return 0;
#if __cplusplus >= 201703L
if (__builtin_constant_p(__n)
&& __constant_char_array_p(__s1, __n)
&& __constant_char_array_p(__s2, __n))
return __gnu_cxx::char_traits<char_type>::compare(__s1, __s2, __n);
#endif
- if (__n == 0)
- return 0;
- else
- return wmemcmp(__s1, __s2, __n);
+ return wmemcmp(__s1, __s2, __n);
}
static _GLIBCXX17_CONSTEXPR size_t
#if __cplusplus >= 201703L
if (__constant_string_p(__s))
return __gnu_cxx::char_traits<char_type>::length(__s);
- else
#endif
- return wcslen(__s);
+ return wcslen(__s);
}
static _GLIBCXX17_CONSTEXPR const char_type*
find(const char_type* __s, size_t __n, const char_type& __a)
{
+ if (__n == 0)
+ return 0;
#if __cplusplus >= 201703L
if (__builtin_constant_p(__n)
&& __builtin_constant_p(__a)
&& __constant_char_array_p(__s, __n))
return __gnu_cxx::char_traits<char_type>::find(__s, __n, __a);
#endif
- if (__n == 0)
- return 0;
- else
- return wmemchr(__s, __a, __n);
+ return wmemchr(__s, __a, __n);
}
static char_type*
static _GLIBCXX17_CONSTEXPR int
compare(const char_type* __s1, const char_type* __s2, size_t __n)
{
+ if (__n == 0)
+ return 0;
#if __cplusplus > 201402
if (__builtin_constant_p(__n)
&& __constant_char_array_p(__s1, __n)
&& __constant_char_array_p(__s2, __n))
return __gnu_cxx::char_traits<char_type>::compare(__s1, __s2, __n);
#endif
- if (__n == 0)
- return 0;
return __builtin_memcmp(__s1, __s2, __n);
}
static _GLIBCXX17_CONSTEXPR const char_type*
find(const char_type* __s, size_t __n, const char_type& __a)
{
+ if (__n == 0)
+ return 0;
#if __cplusplus > 201402
if (__builtin_constant_p(__n)
&& __builtin_constant_p(__a)
&& __constant_char_array_p(__s, __n))
return __gnu_cxx::char_traits<char_type>::find(__s, __n, __a);
#endif
- if (__n == 0)
- return 0;
return static_cast<const char_type*>(__builtin_memchr(__s, __a, __n));
}
--- /dev/null
+// Copyright (C) 2019 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 -fexceptions -fnon-call-exceptions -O1" }
+// { dg-do run { target { powerpc*-*-linux* i?86-*-linux* x86_64-*-linux* } } }
+// { dg-require-effective-target c++17 }
+
+#include <string_view>
+
+int main()
+{
+ std::string_view s1, s2;
+ return s1 != s2;
+}
--- /dev/null
+// Copyright (C) 2019 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 -fexceptions -fnon-call-exceptions -O1" }
+// { dg-do run { target { powerpc*-*-linux* i?86-*-linux* x86_64-*-linux* } } }
+// { dg-require-effective-target c++17 }
+
+#include <string_view>
+
+int main()
+{
+ std::wstring_view s1, s2;
+ return s1 != s2;
+}