Hi,

AFAICS the code in build_round_expr implicitly assumes that __float128 exists, 
which is *not* the common case among 64-bit architectures since "long double" 
is generally already 128-bit for them.

Tested on x86-64/Linux and SPARC64/Linux, OK for the mainline?


2021-03-08  Eric Botcazou  <ebotca...@adacore.com>

        PR fortran/96983
        * trans-intrinsic.c (build_round_expr): Do not implicitly assume
        that __float128 is the 128-bit floating-point type.

-- 
Eric Botcazou
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 5c9258c65c3..ae359a07973 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -407,7 +407,10 @@ build_round_expr (tree arg, tree restype)
       if (kind < 0)
 	gfc_internal_error ("Could not find real kind with at least %d bits",
 			    resprec);
-      arg = fold_convert (gfc_float128_type_node, arg);
+      if (gfc_real16_is_float128)
+	arg = fold_convert (gfc_float128_type_node, arg);
+      else
+	arg = fold_convert (long_double_type_node, arg);
       fn = gfc_builtin_decl_for_float_kind (BUILT_IN_ROUND, kind);
     }
   else

Reply via email to