[llvm-bugs] [Bug 12531] Reverse loop order with variable upper boundary not handled correctly by analyzer
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 29 01:44:35 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=12531
Ehud Katz <ehudkatz at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |ehudkatz at gmail.com
Resolution|--- |INVALID
--- Comment #6 from Ehud Katz <ehudkatz at gmail.com> ---
(In reply to Jörg Sonnenberger from comment #0)
> Consider this code:
>
> void f(int j)
> {
> void *buf[j];
> int i;
> if (j < 0)
> return;
> for (i = 0; i < j; ++i)
> buf[i] = malloc(100);
> #if WORKING
> for (i = 0; i < j; ++i)
> #else
> for (i = j - 1; i >= 0; ++i)
> #endif
> free(buf[i]);
> }
>
> The two for loops in the #if are equivalent, but the second triggers the
> "use of potentially uninitialised memory" check.
Those loops are not equivalent. The analyzer is correct.
The second loop should have `--i` instead of `++i`.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191029/8c66b470/attachment.html>
More information about the llvm-bugs
mailing list