c - Is it legal to assign a restricted pointer to another pointer, and use the second pointer to modify the value? -



c - Is it legal to assign a restricted pointer to another pointer, and use the second pointer to modify the value? -

does next method respect "restrict" contract?

void fun(int* restrict foo) { int* bar = foo + 32; (int = 0; < 32; ++i) *bar = 0; }

my guess no, need clarification.

yes, sure respects contract.

6.7.3 type qualifiers

8 object accessed through restrict-qualified pointer has special association pointer. association, defined in 6.7.3.1 below, requires accesses object use, straight or indirectly, value of particular pointer.135) intended utilize of restrict qualifier (like register storage class) promote optimization, , deleting instances of qualifier preprocessing translation units composing conforming programme not alter meaning (i.e., observable behavior).

in short, @ point foo defined (the function-call), foo guaranteed programmer way refer objects (if any) points to. other expressions referring object must derived pointers value (like bar set foo+32). breaking faith is, in such cases, duly punished undefined behavior.

c c99 restrict-qualifier

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -