https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125606

Harald Anlauf <anlauf at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|anlauf at gmx dot de               |

--- Comment #15 from Harald Anlauf <anlauf at gcc dot gnu.org> ---
(In reply to Jerry DeLisle from comment #14)
> LOC is a non standard function apparently provided by many compilers.
> Probably dates back to well before C_LOC existed. Did this work in 14? If
> so, I suppose we should fix it.

Agreed.

I suspect a problem with gfc_conv_array_parameter, which tries to do more
than is needed.

Next try:

diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index fdb9ddb52ea..0a0c6525dd7 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -9830,7 +9830,11 @@ gfc_conv_intrinsic_loc (gfc_se * se, gfc_expr * expr)
       gfc_conv_expr_reference (se, arg_expr);
     }
   else
-    gfc_conv_array_parameter (se, arg_expr, true, NULL, NULL, NULL);
+    {
+      gfc_conv_expr_descriptor (se, arg_expr);
+      se->expr = gfc_conv_descriptor_data_get (se->expr);
+    }
+  se->expr = gfc_evaluate_now (se->expr, &se->pre);
   se->expr = convert (gfc_get_int_type (gfc_index_integer_kind), se->expr);

   /* Create a temporary variable for loc return value.  Without this,


This brings the actual LOC implementation somewhat closer to C_LOC.

Reply via email to