why optimization does not happen?

Posted by aaa on Stack Overflow See other posts from Stack Overflow or by aaa
Published on 2010-04-23T18:48:32Z Indexed on 2010/04/23 18:53 UTC
Read the original article Hit count: 184

Filed under:
|
|
|

hi.

I have C/C++ code, that looks like this:

static int function(double *I) {
    int n = 0;
    // more instructions, loops,
    for (int i; ...; ++i)
        n += fabs(I[i] > tolerance);
    return n;
}

function(I); // return value is not used.

compiler inlines function, however it does not optimize out n manipulations. I would expect compiler is able to recognize that value is never used as rhs only. Is there some side effect, which prevents optimization?

Thanks

© Stack Overflow or respective owner

Related posts about c

    Related posts about c++