Hi Tobias,

> Fortran 2008 supports  C_LOC(array); if the argument is not simply
> contiguous, the current code adds a call to __gfortran_intrinsic_pack.
>
> The pack call shouldn't be there. Fortran 2008 demands that the actual
> argument is contiguous and intrinsic_pack copy creates a copy if the
> run-time check shows that the argument is not contiguous. Thus, it is not a
> wrong-code issue. However, for performance reasons, it makes sense to avoid
> the call __gfortran_intrinsic_pack.
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?

finally found a few silent minutes to have a look at this patch.

What I don't quite understand is:


@@ -6317,8 +6317,13 @@ conv_isocbinding_function (gfc_se *se, gfc_expr *expr)
     {
       if (arg->expr->rank == 0)
     gfc_conv_expr_reference (se, arg->expr);
-      else
+      else if (gfc_is_simply_contiguous (arg->expr, false))
     gfc_conv_array_parameter (se, arg->expr, true, NULL, NULL, NULL);
+      else
+    {
+      gfc_conv_expr_descriptor (se, arg->expr);
+      se->expr = gfc_conv_descriptor_data_get (se->expr);
+    }


Why doesn't 'gfc_conv_array_parameter' handle this situation properly?
After all there is code like this inside:

  no_pack = (...)
              ||
         gfc_is_simply_contiguous (expr, false));


Wouldn't it be better to fix the logic in there, instead of avoiding
to call it alltogether? This might also help in other situations ...

Cheers,
Janus

Reply via email to