Part of original report: I have recently had the chance to compile some code using -Wconversion and a loop that may iterate more than 2.2 billion times. There is a compiler warning of this sort which I cannot resolve:
nell:~/work/bit barnes$ gfortran -Wconversion -o t.x testcase.f testcase.f:7.16: do i=1_8,n 1 Warning: Conversion from INTEGER(4) to INTEGER(8) at (1) --- program testcase implicit none integer(8) i,n n=1_8 do i=1_8,n enddo end --- The only variables in the testcase are 8-byte integers, yet I get that conversion warning. I skimmed the gfortran bugzilla and did not notice anything similar. If the loop is executed 2.2 billion times (n=2 200 000 000_8), it does run each instance, so I know the do loop is not being truncated at the limit of a 4-byte integer. --- nell:~/work/bit barnes$ gfortran -v Using built-in specs. Target: i686-apple-darwin8 Configured with: ../gcc-4.2.2/configure --prefix=/sw --prefix=/sw/lib/gcc4.2 --mandir=/sw/share/man --infodir=/sw/share/info --enable-languages=c,c++,fortran,objc,java --with-arch=nocona --with-tune=generic --host=i686-apple-darwin8 --with-gmp=/sw --with-libiconv-prefix=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib Thread model: posix gcc version 4.2.2 Part of reply from Tobias Burnus (he asked me to file a bug report): The problem is that the iterator step variable is INTEGER(4) [implicitly added "1_4" ("gfc_int_expr (1);")]: do i = 1_8, n, 1_4 Something like the following should work: Index: gcc/fortran/match.c =================================================================== --- gcc/fortran/match.c (revision 131912) +++ gcc/fortran/match.c (working copy) @@ -958,6 +965,8 @@ gfc_match_iterator (gfc_iterator *iter, if (gfc_match_char (',') != MATCH_YES) { e3 = gfc_int_expr (1); + if (var->ts.type == BT_INTEGER) + e3->ts.kind = var->ts.kind; goto done; } -- Summary: spurious warning using -Wconversion, a do loop, and 8 byte integers Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bcbarnes at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35003