A char *
(and qualified variants) may alias anything.
Are signed char *
and unsigned char *
(and their qualified variants)
exempt from this?
In other words, I've learned it's a good idea to apply restrict
to char*
function arguments if I don't expect them to alias pointer parameters of other types (because they could alias them):
int func(struct foo *f, char * restrict s /*different object*/);
can I drop the restrict
keyword for signed and unsigned char variants like so?
int sfunc(struct foo *f, signed char *s /*different object*/);
int ufunc(struct foo *f, unsigned char *s /*different object*/);
Also may pointers to a signed and unsigned variant of the same type
alias each other? In other words if I expect a pointer to an int and a pointer to an unsigned and they should point to different objects, should the int *
and unsigned *
parameters each be restrict
-qualified?
/* i and u should be different */
int uifunc(int * /*restrict?*/ i, unsigned * /*restrict?*/ u);
restrict
in the prototype is not significant (although it serves as documentation) - only the version in the function definition has an effect – Literacy