What does the restrict qualifier on a pointer parameter promise the compiler?
Correct answer
A. That the object it points to is accessed only through that pointer and pointers derived from it within the block
18 views
A. That the object it points to is accessed only through that pointer and pointers derived from it within the block
18 views
restrict is an aliasing promise: if the object is modified through another independent pointer during the block, behaviour is undefined, which lets the compiler reorder and vectorise loads and stores. It is used in memcpy to justify assuming source and destination do not overlap, unlike memmove. It says nothing about nullness or constness, which are separate qualifiers and contracts.
Asked in: NTS, PPSC IT, Campus Interviews
Not sure why the answer is A? Ask here and get an explanation.