[PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions
LIU Hao
lh_mouse@126.com
Fri Jul 5 15:54:22 GMT 2024
在 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20240705/671f35aa/attachment.sig>
More information about the Gcc
mailing list