abs(__GLIBCXX_TYPE_INT_N_3 __x) { return __x >= 0 ? __x : -__x; }
#endif
+#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
+ // In strict modes __GLIBCXX_TYPE_INT_N_0 is not defined for __int128,
+ // but we want to always define std::abs(__int128).
+ __extension__ inline _GLIBCXX_CONSTEXPR __int128
+ abs(__int128 __x) { return __x >= 0 ? __x : -__x; }
+#endif
+
#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
constexpr _Float16
abs(_Float16 __x)
{ return __gnu_cxx::__bfloat16_t(__builtin_fabsf(__x)); }
#endif
-#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
+#if defined(_GLIBCXX_USE_FLOAT128)
__extension__ inline _GLIBCXX_CONSTEXPR
__float128
abs(__float128 __x)
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__ -D__STRICT_ANSI__" }
+// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
// { dg-do compile { target c++11 } }
+// // { dg-add-options strict_std }
#define conf_hyperg 1
#define conf_hypergf 2
--- /dev/null
+// { dg-do compile }
+// { dg-add-options strict_std }
+
+#include <cstdlib>
+
+template<typename T> T same_type(T, T) { return T(); }
+
+#ifdef __SIZEOF_INT128__
+__int128 i = 0;
+__int128 j = same_type(std::abs(i), i);
+#endif
+
+#ifdef __SIZEOF_FLOAT128__
+__float128 f = 0.0;
+__float128 g = same_type(std::abs(f), f);
+#endif