warning 94:comparison is always false due to limited range of data type

Help
yantrak
2014-05-25
2014-06-15
  • yantrak
    yantrak
    2014-05-25

    the code below:

    void wait (unsigned int ms,unsigned int us)
    {unsigned int J,k;
    if (ms != 0) us =70;
    for (k = 0;k <= ms;k++)
    for (J = 0;J <= us;J++)
    {
    }
    }

    results in warning 94:comparison is always false due to limited range of data type

    this is for the 2 for statements in the code.

    addendum:

    sorry for missing out earlier.

    can anyone please help regarding the reason for the warning.?

     
    Last edit: yantrak 2014-05-25
  • Maarten Brock
    Maarten Brock
    2014-06-15

    This is a bug in SDCC. Please report it as such in the bug tracker.

    What happens is that SDCC tries to find out if the initial value of the for loop iterator (J=0) always gives a true condition (J<=us) because then it can remove the initial check and only check at the end of the loop. Since 0 is always <= any unsigned int this is true and SDCC can perform the optimization. However while checking this it also generates a warning which it shouldn't.

    Maarten