public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/35037]  New: VOLATILE attribute not being honored with common block variable
@ 2008-01-31  4:47 w6ws at earthlink dot net
  2008-01-31  5:08 ` [Bug fortran/35037] " w6ws at earthlink dot net
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: w6ws at earthlink dot net @ 2008-01-31  4:47 UTC (permalink / raw)
  To: gcc-bugs

The following code demonstrates that when optimization is turned on, the memory
reference is being moved out of the loop.  Thus, the volatile attribute is not
being honored.

As a workaround (and perhaps better solution), the user could use a module
instead of a common block.  Gfortran works ok in the case of module variables.

The below example is from x86 cygwin.  But the same thing happens with x86_64
Linux on the current trunk.

$ cat vol.f
      subroutine wait4it ()
        implicit none

        logical event
        volatile event
        common /xyzzy/ event

        do
          if (event) exit
        end do

      end subroutine

$ gfortran -O -S vol.f

$ cat vol.s
        .file   "vol.f"
        .text
.globl _wait4it_
        .def    _wait4it_;      .scl    2;      .type   32;     .endef
_wait4it_:
        pushl   %ebp
        movl    %esp, %ebp
        cmpl    $0, _xyzzy_
        jne     L4
L5:
        jmp     L5
L4:
        popl    %ebp
        ret
        .comm   _xyzzy_, 16      # 4

$

$ gfortran --version
GNU Fortran (GCC) 4.3.0 20071222 (experimental) [trunk revision 127783]
Copyright (C) 2007 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING


$


-- 
           Summary: VOLATILE attribute not being honored with common block
                    variable
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: w6ws at earthlink dot net
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


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


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

end of thread, other threads:[~2008-02-05 21:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-31  4:47 [Bug fortran/35037] New: VOLATILE attribute not being honored with common block variable w6ws at earthlink dot net
2008-01-31  5:08 ` [Bug fortran/35037] " w6ws at earthlink dot net
2008-01-31 14:35 ` burnus at gcc dot gnu dot org
2008-02-01 22:55 ` fxcoudert at gcc dot gnu dot org
2008-02-04 20:59 ` burnus at gcc dot gnu dot org
2008-02-04 22:52 ` fxcoudert at gcc dot gnu dot org
2008-02-05  0:42 ` fxcoudert at gcc dot gnu dot org
2008-02-05  1:25 ` w6ws at earthlink dot net
2008-02-05 21:08 ` fxcoudert at gcc dot gnu dot org
2008-02-05 21:08 ` fxcoudert 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).