https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122278
Bug ID: 122278
Summary: ICE in gfc_typenode_for_spec with parameter with
proc-pointer component
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Target Milestone: ---
The following program fails with:
Error: Expected a procedure pointer for argument āpā
if I leave a line in like 'call sub(pp%ppt)' or
'associated (pp%ppt)' [while 'associated(p, pp%ppt)' seems to work].
I am not quite sure whether that's a 'rejects-valid' bug - or perfectly as
expected.
However, the code (with 'call sub' or without) compiles with 'flang' and 'ifx';
it compiles but ICEs with 'ifort'.
* * *
For the following (i.e. as below with 'call sub' commented), I am also
not sure whether that's an 'ice-on-valid-code' or 'ice-on-invalid-code',
but surely the ICE is wrong:
11 | print *, len(pp%ppt())
| 1
internal compiler error: in gfc_typenode_for_spec, at
fortran/trans-types.cc:1331
0x25d39ad internal_error(char const*, ...)
../../../repos/gcc/gcc/diagnostic-global-context.cc:787
0x9f6593 fancy_abort(char const*, int, char const*)
../../../repos/gcc/gcc/diagnostics/context.cc:1806
0x7d401a gfc_typenode_for_spec(gfc_typespec*, int)
../../../repos/gcc/gcc/fortran/trans-types.cc:1331
0xbe8e42 gfc_sym_type(gfc_symbol*, bool)
../../../repos/gcc/gcc/fortran/trans-types.cc:2517
0xbe7459 gfc_get_function_type(gfc_symbol*, gfc_actual_arglist*, char const*)
../../../repos/gcc/gcc/fortran/trans-types.cc:3584
0xb5d5eb gfc_get_extern_function_decl(gfc_symbol*, gfc_actual_arglist*, char
const*)
../../../repos/gcc/gcc/fortran/trans-decl.cc:2437
0xb7b02c conv_function_val
../../../repos/gcc/gcc/fortran/trans-expr.cc:4779
-----------------------
implicit none (type, external)
type t
procedure(deferred_len), pointer, nopass :: ppt => null()
end type t
type(t), parameter :: pp = t()
procedure(deferred_len), pointer :: x
x => pp%ppt
! call sub(pp%ppt) ! Error: Expected a procedure pointer for argument āpā
if (.false.) &
print *, len(pp%ppt())
contains
subroutine sub(p)
procedure(), pointer :: p
end
function deferred_len()
character(len=:), allocatable :: deferred_len
end
end