在 2024-07-05 23:23, Alejandro Colomar via Gcc 写道:
Hi Martin, On Fri, Jul 05, 2024 at 05:02:15PM GMT, Martin Uecker wrote:But when the thing gets non-trivial, as in strtol(3), GCC misses the -Wrestrict diagnostic, as reported in
A pointer to `char` can alias any object, so in theory one could write code that looks like below. This piece of code is probably nonsense, but it illustrates the exact necessity of the `restrict` qualifiers:
char* dumb(char* p) { strtol((const char*) &p, &p, 0); return p; } // warning: passing argument 2 to 'restrict'-qualified parameter // aliases with argument 1 -- Best regards, LIU Hao
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature