This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Too many warnings.
>On Jul 2, 1999, Gvran Uddeborg <uddeborg@carmen.se> wrote:
>
>> I do understand that there is a value being ignored here. But that is
>> true for the statement
>
>> i=1;
>
>> too.
>
>But this is so common that it wouldn't make sense to issue a warning
>in this case.
The point is not that it is common, rather that the *purpose* of `=' is
to perform a "side effect", i.e. of modifying one of its operands.
So, as a "zero-level" operator in a statement, `=' *does* have an effect,
regardless of whether any of its *operands* has (side) effects.
`&&' does not modify its operands, so, as the only zero-level operator in
a statement, it is entirely appropriate that gcc warn about the statement
having, at its zero level anyway, no effect. (Perhaps the diagnostic
could be clarified?)
tq vm, (burley)
P.S. By "zero-level" I mean that, in "i++ && (j=84);", `&&' is the
zero-level operator, while `++' and `=' are one-level operators, i.e.
they're a level further away from the top, or zero, level of the
AST resulting from a canonical parse of this particular statement.