This is the mail archive of the egcs-bugs@egcs.cygnus.com mailing list for the EGCS project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Too many warnings.


>Would this make sense: if `&&', `||' is a zero-level operator, then
>the right-hand side is analysed recursively.  As if it were a
>zero-level expression itself.  So a warning should be issued if it is
>a plain value, or an operator like `+'.  No warning is issued if it is
>one like `=', or a function call.  And the algorithm is applied again
>if it is `&&' or `||'.
>
>For `?:' a warning should be issued only if BOTH the "middle hand" AND
>the right hand argument motivates a warning.

I think that's more complicated than necessary.  Warning that
the construct is equivalent to an `if' statement is probably best,
now that I think more about it.

>I believe this would catch most errors, while still allowing the
>typical use in macros.

I believe the macro issue is best solved by *not* warning when the
whole expression is enclosed in parens:

  (i++ && (j += 5));

After all, it's unwise to define a macro thusly:

  #define macro(l,m) l++ && (m += 5)

Even putting the *arguments* within parens does not necessarily avoid
the danger of an operator near the expansion affecting the precedence
of that expansion:

  moo = cow + macro (pig, goat);

This turns into:

  moo = cow + pig++ && (goat += 5);

Which I believe is interpreted as if it read:

  moo = (cow + pig++) && (goat += 5);

        tq vm, (burley)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]