This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54893] unable to access volatile variable within relaxed transaction
- From: "spear at cse dot lehigh.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 11 Oct 2012 13:21:19 +0000
- Subject: [Bug c++/54893] unable to access volatile variable within relaxed transaction
- Auto-submitted: auto-generated
- References: <bug-54893-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54893
--- Comment #2 from Mike Spear <spear at cse dot lehigh.edu> 2012-10-11 13:21:19 UTC ---
There is a key difference here. The transaction in my example is /relaxed/.
According to the specification, there are no restrictions on what a relaxed
transaction can do. Relaxed transactions can call unsafe functions, do I/O,
acquire locks, execute inline asm, etc. And access to C++11 atomics and C11
volatiles is definitely legal in relaxed transactions.
If I understand the GCC TM implementation correctly, immediately before the
attempt to access a volatile within the relaxed transaction, the transaction
will need to become serial irrevocable, after which point it can continue to
access and directly modify volatile variables.
Note that a workaround for the time being is to move the volatile access into a
function, to *not* mark the function [[transaction_callable]], and then to call
the function instead of accessing the volatile directly. This will achieve the
exact same behavior as is expected, though with the overhead of a function call
on each volatile access within a relaxed transaction. However, longer term
this is definitely a bug in the current implementation.