[Bug c++/54893] unable to access volatile variable within relaxed transaction

spear at cse dot lehigh.edu gcc-bugzilla@gcc.gnu.org
Thu Oct 11 13:21:00 GMT 2012


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.



More information about the Gcc-bugs mailing list