This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PR 56419/c++]: C++ front end silently drops transactions
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>, Richard Henderson <rth at redhat dot com>
- Date: Fri, 22 Feb 2013 08:53:46 -0600
- Subject: [PR 56419/c++]: C++ front end silently drops transactions
In the following snippet, the C++ front-end drops the transaction
altogether:
+int x = 0;
+int inc_func(int i) {
+ for (int j = 0; j < i; ++j)
+ {
+ __transaction_atomic { x+=1; }
+ }
+ return 0;
This was caused by http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186546
The problem here is that genericize_cp_loop() calls
append_to_statement_list() to add the TRANSACTION_EXPR, but in this
case, TREE_SIDE_EFFECTS is not set, so it is silently ignored.
Frankly, I don't understand finish_transaction_stmt(), and why it sets
TREE_SIDE_EFFECTS only if the [noexcept] clause is set. I'm C++
ignorant, but I would've thought the opposite to be true.
Anyways, I've fixed the problem by setting TREE_SIDE_EFFECTS if the
transaction body has side effects. Perhaps we should do this for
build_transaction_expr() as well?
What do y'all prefer?
Attachment:
curr
Description: Text document