public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50364] New: Volatile miscompilation
@ 2011-09-12  9:16 abramobagnara at tin dot it
  2011-10-12 15:55 ` [Bug c++/50364] " paolo.carlini at oracle dot com
  2011-10-13  8:43 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: abramobagnara at tin dot it @ 2011-09-12  9:16 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50364
           Summary: Volatile miscompilation
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: abramobagnara@tin.it


$ cat p.cc
volatile int a, b;
void f() {
  b = 1 + (a = 0);
}
$ g++ -O2 -S p.cc
$ cat p.s
        .file   "p.cc"
        .text
        .p2align 4,,15
        .globl  _Z1fv
        .type   _Z1fv, @function
_Z1fv:
.LFB0:
        .cfi_startproc
        movl    $0, a
        movl    $1, b
        ret
        .cfi_endproc
...

As the typescript above shows, the conversion between lvalue (a = 0) and
relative rvalue does not generate a volatile read memory access unlike what I
think that standard mandates.


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

* [Bug c++/50364] Volatile miscompilation
  2011-09-12  9:16 [Bug c++/50364] New: Volatile miscompilation abramobagnara at tin dot it
@ 2011-10-12 15:55 ` paolo.carlini at oracle dot com
  2011-10-13  8:43 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-12 15:55 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-12 15:54:19 UTC ---
Doesn't look like a C++ front-end issue.


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

* [Bug c++/50364] Volatile miscompilation
  2011-09-12  9:16 [Bug c++/50364] New: Volatile miscompilation abramobagnara at tin dot it
  2011-10-12 15:55 ` [Bug c++/50364] " paolo.carlini at oracle dot com
@ 2011-10-13  8:43 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-10-13  8:43 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-10-13 08:43:10 UTC ---
That works as designed.  See the recent discussion about this very topic
on the gcc mailinglist and

2010-08-19  Nathan Sidwell  <nathan@codesourcery.com>
            Richard Guenther  <richard.guenther@gmail.com>

        * gimplify.c (gimplify_modify_expr): When assigning to volatiles,
        copy the src value and return a copy.
        * doc/extend.texi (Volatiles): Move from C++ to C and expand.
        (C++ Volatiles): Adjust to describe C++ semantics only.

esp.

"Assignments are also expressions and have an rvalue.  However when
assigning to a scalar volatile, the volatile object is not reread,
regardless of whether the assignment expression's rvalue is used or
not.  If the assignment's rvalue is used, the value is that assigned
to the volatile object.  For instance, there is no read of @var{vobj}
in all the following cases:

@smallexample
int obj;
volatile int vobj;
vobj = @var{something};
obj = vobj = @var{something};
obj ? vobj = @var{onething} : vobj = @var{anotherthing};
obj = (@var{something}, vobj = @var{anotherthing});
@end smallexample

If you need to read the volatile object after an assignment has
occurred, you must use a separate expression with an intervening
sequence point."


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

end of thread, other threads:[~2011-10-13  8:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-12  9:16 [Bug c++/50364] New: Volatile miscompilation abramobagnara at tin dot it
2011-10-12 15:55 ` [Bug c++/50364] " paolo.carlini at oracle dot com
2011-10-13  8:43 ` rguenth 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).