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

imitrichev <imitrichev at muctr dot ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |imitrichev at muctr dot ru

--- Comment #6 from imitrichev <imitrichev at muctr dot ru> ---
I think, while patching one should consider also warn on `for` loop empty body.

Whilst we can write something like

    int i=0;
    for (; i<5; a[i]=10, i++);

it is assumed to be not a great programming style.

    int main()
    {
        for (; 1<2; );
        if (1==1);
        while (1==1);
        return 0;
    }

Now it warns only on `if` loop:

g++ empty.cpp -Wempty-body -o empty.out

empty.cpp: In function "int main()":
empty.cpp:4:10: warning: suggest braces around empty body in an «if» statement
[-Wempty-body]

It is really would be helpful to detect infinite loops caused by odd ';' after
`for` and `while` without debugger.

Reply via email to