public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/35003]  New: spurious warning using -Wconversion, a do loop, and 8 byte integers
@ 2008-01-28 21:53 bcbarnes at gmail dot com
  2008-01-29 10:23 ` [Bug fortran/35003] " fxcoudert at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: bcbarnes at gmail dot com @ 2008-01-28 21:53 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-05-10 19:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-28 21:53 [Bug fortran/35003] New: spurious warning using -Wconversion, a do loop, and 8 byte integers bcbarnes at gmail dot com
2008-01-29 10:23 ` [Bug fortran/35003] " fxcoudert at gcc dot gnu dot org
2008-01-29 17:49 ` dfranke at gcc dot gnu dot org
2008-01-30 23:06 ` manu at gcc dot gnu dot org
2009-03-29  8:05 ` fxcoudert at gcc dot gnu dot org
2010-05-09 19:30 ` dfranke at gcc dot gnu dot org
2010-05-10 17:12 ` dfranke at gcc dot gnu dot org
2010-05-10 19:24 ` dfranke at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).