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

--- Comment #1 from Alexander Zaitsev <zamazan4ik at tut dot by> ---
Same for code without using STL algorithms and containers:

int min(int a, int b)
{
    return a < b ? a : b;
}

int max(int a, int b)
{
    return a > b ? a : b;
}

int foo(int* v, int size) {
    int l = v[0];
    for(int i=0; i < size; ++i)
    {
        l = min(l, v[i]);
    }

    for(int i=0; i < size; ++i)
    {
        l = max(l, v[i]);
    }

    return l;
}


Result of function doesn't depend on the result of first loop and it can be
eliminated.

Reply via email to