On Mon, 2012-01-02 at 19:10 +0100, Torvald Riegel wrote:
> - Do we potentially get unnecessary warnings (if vars are live across
>   a transaction begin)?  I didn't get such warnings in the STAMP app
>   that wasn't working though.  Does anyone has suggestions for a test
>   case?

Attached is a test that raises a warning.  This requires g++ and
-Wclobbered (-Wall is not sufficient), so it might still be okay until
we have a proper solution.

Interestingly (at least to me), I wasn't able to construct a test on my
own (see main2() for my attempts...), but had to web-search for one (see
main()).  Is the warning actually supposed to always trigger?  We only
seem to have a test for a case where there should be _no_ warning.
/* { dg-do compile } */
/* { dg-options "-fgnu-tm -Wclobbered -O" } */
#include <vector>

extern int foo(int);
extern int y;
int main2() {
  int i;
  int x[123];
  int sum = 0;
  x[5] += x[6] = 10;
  for (i=0; i < 100; i++) {
    __transaction_atomic {
      y=12;
    }
    x[i] += x[5] + x[6] + i;
    sum += x[i];
  }
  // and again, without loop.
  __transaction_atomic {
    y=12;
  }
  x[i] += x[5] + x[6] + i;
  sum += x[i];
  return foo(x[x[12]]) + sum;
}

int main() {
 std::vector<int> foo(y);
 __transaction_atomic { y = 13; }
 return 1;
}

Reply via email to