Hi!
On Wed, Jun 25, 2014 at 03:36:38PM +0200, Marek Polacek wrote:
> static void __attribute__ ((noinline, noclone))
> fn7 (void)
> {
> - int n = 5, i;
> + int n = 5;
> + volatile int i;
> volatile int c[n][n][n];
> - c[5][2][2] = 2;
> - c[2][5][2] = 2;
> - c[2][2][5] = 2;
> + asm ("" : : "r" (&c[5][2][2]) : "memory");
> i = c[5][2][2];
> + asm ("" : : "r" (&c[2][5][2]) : "memory");
> i = c[2][5][2];
> + asm ("" : : "r" (&c[2][2][5]) : "memory");
> i = c[2][2][5];
Please don't invoke undefined behavior in the asm statements.
So, "r" (&c[5]) is fine, but not &c[5][2][2] is not, &x[-1] is not, etc.
I'd say it should be ok to always just take address of the base
variable in the asm. Otherwise it looks good to me.
Jakub