This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]