http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51302
Bug #: 51302 Summary: ICE with VOLATILE loop variable Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org The following program ICEs for me with GCC 4.4 and 4.7. It does not ICE for me with 4.3, 4.4, 4.5 and 4.6 though I think that's because those do not have tree checking enabled. $ gfortran foo.f90 # << 4.7 foo.f90: In function ‘MAIN__’: foo.f90:3:0: internal compiler error: in gfc_add_modify_loc, at fortran/trans.c:161 That's a check whether: t1 = TREE_TYPE (rhs); t2 = TREE_TYPE (lhs); gcc_assert (t1 == t2 || AGGREGATE_TYPE_P (TREE_TYPE (lhs))); Seemingly, the problem arises as one type is volatile and the other is not, i.e., one probably needs to add a fold_convert which strips off the volatile. As no one may modify the loop variable in the loop, stripping off should be perfectly valid. integer, volatile :: i integer :: n = 1 do i = 1, n end do end