[Bug c++/94575] Bogus warning: Used variable is “not” used

bisqwit at iki dot fi gcc-bugzilla@gcc.gnu.org
Mon Apr 20 17:00:53 GMT 2020


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

--- Comment #2 from Joel Yliluoma <bisqwit at iki dot fi> ---
Sorry, the error Marek Polacek mentions is due to a copypaste mistake on my
part. The correct code that demonstrates the problem is here. The difference is
the && instead of &.

#include <cstdio>
template<typename T>
static void Use(T&& plot)
{
    plot(1);
}
int main()
{
    static const int table[1] = {123456};
    Use([&](auto x)
    {
        unsigned var = table[x];
        unsigned ui = var;
        std::printf("%u\n", ui);
    });
}


More information about the Gcc-bugs mailing list