[Bug fortran/106500] ICE on function as an argument to c_sizeof()

kargl at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Aug 1 19:47:31 GMT 2022


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

--- Comment #1 from kargl at gcc dot gnu.org ---
Changed subject as it's unclear whether it is invalid or not.  In any case, 
this patch allows the code to compile and it produces the expected output.

% gfcx -o z a.f90
% ./z
4
16


diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc
index 0c2cb50c6a7..b9d460f133e 100644
--- a/gcc/fortran/check.cc
+++ b/gcc/fortran/check.cc
@@ -5266,6 +5266,9 @@ is_c_interoperable (gfc_expr *expr, const char **msg,
bool c_loc, bool c_f_ptr)
       return false;
     }

+  if ( expr->expr_type == EXPR_FUNCTION)
+    return true;
+
   if (!c_loc && expr->rank > 0 && expr->expr_type != EXPR_ARRAY)
     {
       gfc_array_ref *ar = gfc_find_array_ref (expr);


More information about the Gcc-bugs mailing list