https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112833
Bug ID: 112833
Summary: Missing warnings on restrict misuse
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: alx at kernel dot org
Target Milestone: ---
Reproducer:
$ cat restrict.c
long bogus_strtol(const char *restrict s, char **restrict ep, int base);
int
main(void)
{
char buf[3] = "foo";
char *p = buf;
bogus_strtol(p, &p, -42);
}
long
bogus_strtol(const char *restrict s, char **restrict ep, int base)
{
**ep = *s;
return base;
}
$ gcc -Wall -Wextra restrict.c -fanalyzer
$ gcc -Wall -Wextra restrict.c -fanalyzer -O3
I'd expect two -Wrestrict warnings, one at call site, and another at `**ep =
*s;`.
BTW, of course, I'd also expect a warning at calls to strtol(3), which I
consider has a wrong use of restrict in the prototype.
Original report at gcc-help@:
<https://inbox.sourceware.org/gcc-help/ZWyw72QNLhzG874z@debian/T/#t>