Consider this code:

  if(a <= b <= c)
       something();

If c is >= 1, then the `if' will always execute something(), because `a <= b'
returns either 0 or 1.
This, obviously, is not an error, but it can mislead some programmers,
therefore it would be nice to have a warning like "warning: suggest parentheses
around inequality used as truth value". In this way, the following code will be
accepted without warnings:
  if((a <= b) <= c)
       something();

That's all ;)


-- 
           Summary: Warning on if(a < b < c) and other similar codes
           Product: gcc
           Version: 3.4.6
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alpt at freaknet dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29193

Reply via email to