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

--- Comment #19 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
(In reply to Andrew Pinski from comment #18)
> *** Bug 119544 has been marked as a duplicate of this bug. ***

The example in this bug was

extern char* str;

void foo(void)
{
    int i = 0;

    while (*str == ' ' || *str == '\t' || *str == '\n' || *str == '\r')
    {
        i++;
        str++;
    }
}

However, the i++ is not completely useless, as this is a way to tell the
compiler that the number of iterations is bounded by INT_MAX (perhaps not very
useful here, but there may be cases where this kind of information could be
used for optimization, e.g. loop unrolling -- there does not seem to be a
standard way to give such information).
  • [Bug c/44677] Warn for variable... vincent-gcc at vinc17 dot net via Gcc-bugs

Reply via email to