[Bug c++/45940] [trans-mem] Error of unsafe function even if annotated

aldyh at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Nov 29 16:27:00 GMT 2010


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

--- Comment #9 from Aldy Hernandez <aldyh at gcc dot gnu.org> 2010-11-29 16:04:18 UTC ---
The -O1 ICE is due to the fact that we have an inline function that has been
marked as transaction_pure, but contains an inline asm.  The following code
sets the 'saw_unsafe' bit, regardless of the transaction_pure attribute:

    case GIMPLE_ASM:
      /* ??? We ought to come up with a way to add attributes to
     asm statements, and then add "transaction_safe" to it.
     Either that or get the language spec to resurrect __tm_waiver.  */
      if (d->block_flags & DIAG_TM_SAFE)
    error_at (gimple_location (stmt),
          "asm not allowed in atomic transaction");
      else if (d->func_flags & DIAG_TM_SAFE)
        error_at (gimple_location (stmt),
          "asm not allowed in %<transaction_safe%> function");
      else
    d->saw_unsafe = true;
      break;

The easy way to solve this, is to pass the fndecl in d->, and check for
transaction_pure attributes.  The hard way, is to add attributes to asm
statements (see comment above), mark asm statements as safe/pure when
appropriate, and never loose this information.

You can guess which way I want to solve it.

Richard?



More information about the Gcc-bugs mailing list