https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125724
Bug ID: 125724
Summary: ICE in gfc_conv_procedure_call passing NULL() to an
allocatable dummy argument
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: jvdelisle at gcc dot gnu.org
Target Milestone: ---
Passing NULL() as an actual argument to an allocatable dummy argument causes an
internal compiler error. In gfc_conv_procedure_call, when a NULL() actual is
associated with a non-pointer dummy, the code asserts that the dummy is
optional
and not allocatable:
/* Pass a NULL pointer to denote an absent arg. */
gcc_assert (fsym->attr.optional && !fsym->attr.allocatable
&& (fsym->ts.type != BT_CLASS
|| !CLASS_DATA (fsym)->attr.allocatable));
An allocatable dummy violates this assertion, so the compiler aborts.
Minimal reproducer:
program p
call sub (null ())
contains
subroutine sub (a)
integer, allocatable, intent(in) :: a
if (allocated (a)) stop 1
end subroutine
end program
Observed:
internal compiler error: in gfc_conv_procedure_call, at
fortran/trans-expr.cc:7208
0x... gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*,
gfc_expr*, vec<tree_node*, va_gc, vl_embed>*)
gcc/fortran/trans-expr.cc:7208
The ICE occurs for scalar and array allocatable dummies, optional and
non-optional, of intrinsic and derived type, e.g.:
integer, allocatable, optional :: dmy ! scalar, optional
integer, allocatable :: a(:) ! array
type(t), allocatable :: a ! derived
There are several existing PRs this may be a duplicate of. its hard to tell.