public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "w6ws at earthlink dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/35037]  New: VOLATILE attribute not being honored with common block variable
Date: Thu, 31 Jan 2008 04:47:00 -0000	[thread overview]
Message-ID: <bug-35037-15045@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2008-01-31  3:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-31  4:47 w6ws at earthlink dot net [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-35037-15045@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).