https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120049
--- Comment #19 from kargls at comcast dot net --- On 5/6/25 18:57, jvdelisle at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120049 > > --- Comment #18 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> --- > Some fall out after the commit. This may be an unrelated regression on 16. > > On 5/6/25 10:59 AM, Steve Kargl wrote: >> On Tue, May 06, 2025 at 07:43:41PM +0200, Harald Anlauf wrote: >>> >>> the new logic misses the following bad code: >>> >>> print *, c_associated(c_loc(val), 42) >>> >>> This now ICEs here. >>> >>> I suggest to not 'return true' too early before all arguments >>> have been checked. >>> >> >> Good catch, Harald. We probably need to check c_ptr_2 first >> if it is present. >> > > As I began to explore this I had just backported our original patch to 15 > branch to do more testing. On 15 I do not get the ICE Harald is seeing but it > is on 16. > > Here I see on 16: > > $ gfc test.f90 > test.f90:5:21: > > 5 | program tests_gtk_sup > | ^ > Error: mismatching comparison operand types > void * > integer(kind=4) > _2 = D.4648 == 42; > test.f90:5:21: internal compiler error: ‘verify_gimple’ failed > 0x22ba961 internal_error(char const*, ...) > ../../trunk/gcc/diagnostic-global-context.cc:517 > 0xe4833e verify_gimple_in_seq(gimple*, bool) > ../../trunk/gcc/tree-cfg.cc:5345 > 0xac296a gimplify_body(tree_node*, bool) > ../../trunk/gcc/gimplify.cc:20916 > 0xac2ba5 gimplify_function_tree(tree_node*) > ../../trunk/gcc/gimplify.cc:21042 > 0x8d12c7 cgraph_node::analyze() > ../../trunk/gcc/cgraphunit.cc:689 > 0x8d3e47 analyze_functions > ../../trunk/gcc/cgraphunit.cc:1265 > 0x8d4dfd symbol_table::finalize_compilation_unit() > ../../trunk/gcc/cgraphunit.cc:2574 > Please submit a full bug report, with preprocessed source (by using > -freport-bug). > Please include the complete backtrace with any bug report. > See <https://gcc.gnu.org/bugs/> for instructions. > > The ICE is somewhere else. > > Harald's test case works fine on 15 with the original patch. > > $ ls > gtk_sup.f90 gtk_sup.mod gtk_sup.o test.f90 > $ rm gtk_sup.mod > $ rm gtk_sup.o > $ gfc15 -c gtk_sup.f90 > $ gfc15 test.f90 > $ ./a.out > F gfortran should issue an error. First, the types of c_ptr_1 and c_ptr_2 need to agree. c_loc(val) is C_PTR and 42 is INTEGER. Second, the types must be C_PTR or C_FUNPTR. Neither is INTEGER.