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

--- Comment #2 from David Binderman <dcb314 at hotmail dot com> ---
It seems that recent gcc trunk can't detect set-but-not-used in this code:

extern int g( int);

void f( int m)
{
        int n;

        n = 0;

        for (int i = 0; i < m; ++i)
        {
                if (g( i))
                {
                        ++n;
                }
        }
}

$ /home/dcb/gcc/results/bin/g++ -c -g -O2  -Wall -Wextra -pedantic apr10b.cc
$

Recent clang trunk can:

$ /home/dcb/llvm/results/bin/clang++ -c -g -O2  -Wall  apr10b.cc
apr10b.cc:8:6: warning: variable 'n' set but not used
[-Wunused-but-set-variable]
        int n;
            ^
1 warning generated.
$

Reply via email to