public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/24406]  New: EQUIVALENCE broken in 32-bit code with optimization -O2
@ 2005-10-17 11:10 mick at nag dot co dot uk
  2005-10-17 11:29 ` [Bug fortran/24406] " pinskia at gcc dot gnu dot org
                   ` (17 more replies)
  0 siblings, 18 replies; 20+ messages in thread
From: mick at nag dot co dot uk @ 2005-10-17 11:10 UTC (permalink / raw)
  To: gcc-bugs

This program demonstrates a problem with Fortran EQUIVALENCE
in 32-bit compilations. The equivalenced value in variable rteps
gets set correctly (as evidenced by the write statement) but too
late - an incorrect value has already been used in the earlier
comparison statement.

Moving the statement
      write (*,*) 'rteps = ', rteps
to just before the comparison avoids the problem.

Compiling with a level of optimization lower than -O2 also
avoids the problem.

The problem does not show up in 64-bit compiles.

      program main
      double precision rteps
      integer irt(2)
      equivalence (rteps,irt)
c     This bit pattern sets rteps = 1.0d0
      irt(1) = Z'00000000'
      irt(2) = Z'3FF00000'
      if (rteps.gt.0.99d0 .and. rteps.lt.1.1d0) then
         write (*,*) '0.99 < rteps < 1.1 : rteps OK'
      else
         write (*,*) 'rteps <= 0.99  or   rteps >= 1.1 : rteps BAD'
      end if
      write (*,*) 'rteps = ', rteps
      end

% gfortran -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/var/tmp/gfortran-20051007/irun
--enable-languages=c,f95
Thread model: posix
gcc version 4.1.0 20051007 (experimental)

% gfortran -Wall -m32 -O0 equiv.f
% ./a.out
 0.99 < rteps < 1.1 : rteps OK
 rteps =    1.00000000000000     

% gfortran -Wall -m32 -O2 equiv.f
% ./a.out
 rteps <= 0.99  or   rteps >= 1.1 : rteps BAD
 rteps =    1.00000000000000


-- 
           Summary: EQUIVALENCE broken in 32-bit code with optimization -O2
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mick at nag dot co dot uk


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


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

end of thread, other threads:[~2006-04-24 10:13 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-17 11:10 [Bug fortran/24406] New: EQUIVALENCE broken in 32-bit code with optimization -O2 mick at nag dot co dot uk
2005-10-17 11:29 ` [Bug fortran/24406] " pinskia at gcc dot gnu dot org
2005-10-17 11:30 ` pinskia at gcc dot gnu dot org
2005-10-17 18:01 ` kargl at gcc dot gnu dot org
2005-10-17 18:01 ` kargl at gcc dot gnu dot org
2005-10-23 22:52 ` pinskia at gcc dot gnu dot org
2005-11-01 20:20 ` tobi at gcc dot gnu dot org
2006-02-06 20:33 ` tkoenig at gcc dot gnu dot org
2006-02-06 20:56 ` [Bug rtl-optimization/24406] " tobi at gcc dot gnu dot org
2006-02-06 20:57 ` sgk at troutmask dot apl dot washington dot edu
2006-02-06 21:01 ` [Bug fortran/24406] " pinskia at gcc dot gnu dot org
2006-03-03 10:08 ` paul dot richard dot thomas at cea dot fr
2006-03-06 21:03 ` pinskia at gcc dot gnu dot org
2006-03-07  7:28 ` paul dot richard dot thomas at cea dot fr
2006-03-23  1:06 ` pinskia at gcc dot gnu dot org
2006-03-23  8:06 ` paul dot richard dot thomas at cea dot fr
2006-03-23 14:54   ` Andrew Pinski
2006-03-23 14:54 ` pinskia at physics dot uc dot edu
2006-04-23  6:07 ` pault at gcc dot gnu dot org
2006-04-24 10:13 ` mick at nag dot co dot uk

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).