https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82976
--- Comment #2 from Janne Blomqvist <jb at gcc dot gnu.org> --- Hmm. I do think r254526 does the right thing (TM). Looking at -ftree-dump-original the frontend doesn't generaty any logical(kind=1) temporary variables. So presumably some optimization pass creates such a thing and then it fails to make sure that type matches some logical(kind=4) variable defines elsewhere (by the frontend, maybe). I also checked with -fdump-tree-all, none of gfortran -O3 realloc_on_assign_16.f90 -fdump-tree-all gfortran -O3 -fno-tree-forwprop realloc_on_assign_16.f90 -fdump-tree-all gfortran -O2 -fno-tree-forwprop realloc_on_assign_16.f90 -fdump-tree-all had any logical(kind=1) variables in any of the tree dumps. It might be that due to the ICE with "-O3 -fno-tree-forwprop" the culprit tree dump is never generated.