public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51638] New: gfortran optimization breaks a single variable used as both input and output for subroutine call
@ 2011-12-20 15:32 bardeau at iram dot fr
  2011-12-20 17:31 ` [Bug fortran/51638] " burnus at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: bardeau at iram dot fr @ 2011-12-20 15:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51638

             Bug #: 51638
           Summary: gfortran optimization breaks a single variable used as
                    both input and output for subroutine call
    Classification: Unclassified
           Product: gcc
           Version: fortran-dev
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: bardeau@iram.fr


Created attachment 26153
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26153
Program fails with -O flag under 32 bits systems

Hello,

the attached program provides 2 subroutines which do not run correctly if the
program is compiled with the optimization option (-O). Since the program
behaves correctly without this option, this sounds like a bug (at least it
severely annoys us). The subroutines are inherited from our Fortran 77 legacy
code, which behaved well with the other compilers (ifc/ifort, g95, ...) for at
least one decade.

* About the test program:
 it should be self-explanatory. The idea it to swap the bytes in 4 and 8 bytes
integers, but I am not sure this is a major point. The key point is that the
same variable is used as 2 different dummy variables (input and output) in the
calling sequence.

 Here is the output when the program fails:
ubuntu-32:~$ gfortran -O test.f90 -o test
(some type mismatch warnings)
ubuntu-32:~$ ./test
 Call to subroutine IEI4EI with single I/O variable failed:
 Input:    2147483647  (int4) =    -1   -1   -1  127  (4 int1)
 Output:   2147483519  (int4) =   127   -1   -1  127  (4 int1)
 Call to subroutine IEI8EI with single I/O variable failed:
 In:   9223372036854775807  (int8) =    -1   -1   -1   -1   -1   -1   -1  127 
(8 int1)
 Out:  9223372036854775679  (int8) =   127   -1   -1   -1   -1   -1   -1  127 
(8 int1)

You can see that the bytes of the output variable are not correctly swapped.


* About the context:
- Many (if not all) 32 bits linux (and MinGW) are affected, including the
latest 32 bits Ubuntu (11.10).
- No 64 bits linux I tested is affected.
- All the gfortran versions seem affected, including latest 4.7.0 20111215
- The optimization seems mandatory to reproduce the bug, although I suspect I
observed the bug without this option in the past.

Thanks for your help. Unfortunately I won't be available for feedback during
Xmas holidays.


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

end of thread, other threads:[~2012-01-09 10:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-20 15:32 [Bug fortran/51638] New: gfortran optimization breaks a single variable used as both input and output for subroutine call bardeau at iram dot fr
2011-12-20 17:31 ` [Bug fortran/51638] " burnus at gcc dot gnu.org
2011-12-20 17:46 ` kargl at gcc dot gnu.org
2012-01-03 10:21 ` bardeau at iram dot fr
2012-01-03 19:05 ` kargl at gcc dot gnu.org
2012-01-04  8:46 ` burnus at gcc dot gnu.org
2012-01-05 10:44 ` bardeau at iram dot fr
2012-01-05 14:27 ` burnus at gcc dot gnu.org
2012-01-08 11:20 ` tkoenig at gcc dot gnu.org
2012-01-08 17:04 ` sgk at troutmask dot apl.washington.edu
2012-01-08 17:37 ` tkoenig at gcc dot gnu.org
2012-01-09  9:20 ` bardeau at iram dot fr
2012-01-09  9:24 ` bardeau at iram dot fr
2012-01-09 10:03 ` burnus at gcc dot gnu.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).