I have two questions regarding the use on __restrict__ qualifiers for function 
arguments in C++:

1) How does it interact with volatile?

  Example, given:

     void foo(volatile int* __restrict__ p1,
              volatile int* __restrict__ p2)
     {
        *p1 = 3;
        if (*p1 == 5) ...;
        *p2 = 4;
     }

  The most desireable for me would be that restrict would indicate that *p1 and 
*p2 were disjoint and allow reordering statement 3 to execute before either 
preceeding statement, but that volatile would indicate that the if expression 
would need to re-fetch *p1 and not assume the results of the first statement.

   However, an alternative (less useful) interpretation is that volatile 
completely overrides restrict: where restrict would allow the compiler to cache 
*p1 in a local register and therefore volatile would prevent this.

   [A completely non-useful interpretation would be that restrict would 
override volatile and that *p1 would be register cached even though that memory 
might be changed by HW or another thread...]

   I haven't been able to deduce which of the above applies from general 
documentation and thought I'd ask people with more expertise in this area.

2) I would expect the compiler to generate a warning for the second foo() call 
below, but it's completely silent even with -Wall.  Is there a reason no 
warning is generated other than this just hasn't been implemented yet?

   int foo(unsigned int& __restrict__ v1,
           unsigned int& __restrict__ v2)
   { ... }

   int a,b,c;
   foo(a,b);
   foo(c,c);


Thanks in advance for any enlightenment here.
-KQ


-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

Reply via email to