Info node (gcc)Warning Options mentions that gcc warns about

            int save_y;
            if (change_y) save_y = y, y = new_y;
            ...
            if (change_y) y = save_y;

However that's not always true, so it looks like gcc does have
the smarts to drop the warning.  Could that be improved?

gcc -W -O does not warn about this snippet, but it does warn with
-DMACRO or -O2.  So it looks like the information that this code
is safe is available but not used.

#define foo(x) (x < 3 ? 0 : x)
#ifndef MACRO
int (foo)(int x) { return foo(x); }
#undef foo
#endif

int bar(int y, const int change_y)
{
    int save_y;
    if (change_y) save_y = y, y = -y;
    y = foo(y);
    if (change_y) y = save_y;
    return y;
}

gcc 4.3.2 on x86_64-unknown-linux-gnu.

-- 
Hallvard

Reply via email to