https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111730

--- Comment #4 from Xavier Cooney <xavier.cooney03 at gmail dot com> ---
I see, thanks for looking into this.

The unreduced test case (which was from a student confused about the error
message) was still passing a value to `malloc` which from the context which gcc
could see wasn't /necessarily/ non-negative.

But the code
```
void foo2(int x) {
    char *a = malloc(x);
    (void) a;
}
```
doesn't trigger the warning, even though `x` could also be negative.

I'm not sure why the extra loops are necessary for the warning to be emitted if
the compiler is trying to warn about any time a potentially negative value
might be passed to `malloc`.

Also the error message reads to me as saying that argument 1 must be in the
range [18446744071562067968, 18446744073709551615] (in which case it would be
incorrect), rather than saying the argument could be in the range (in which
case it would be correct).

Thanks again for look into this :)

Reply via email to