gcc warn unreached else {}

Jonny Grant jg@jguk.org
Thu Jul 9 09:45:38 GMT 2020


Hello!

There is an example below, (my code is not like this example below). I'm reporting a possible issue, and asking if there is a way to detect it in code bases. If it's a real issue I can file a bug report on Bugzilla.

Can gcc warn where code will not get to the 'return 3;' below?

Cheers, Jonny


int main(void)
{
    const int i = 1;
    if(1 == i)
    {
        return 1;
    }
    else if(1 != i)
    {
        return 2;
    }
    else
    {
        return 3;
    }
}



More information about the Gcc-help mailing list