Some sdcc warnings

  • Vineet

    Vineet - 2007-03-21

    Hello group,
      Have recently started using the SDCC compiler for 8051 controllers.
    I found two warnings coming up when I compile the code.

    1. warning 126 : unreachable code.
    2. warning 59 : conditional flow changed by optimizer.


    1.Can anyone tell me what this means?
    2.Also can they be ignored?

    Best Regards,

    • Anonymous - 2007-03-22

      Hi Vineet,

      1. Unreachable code means, that the compiler thinks, that there is no way that a specific code will ever execute. Example:
      while (1) ;
      <unreachable code>
      You probably don't want to ignore this warning unless you explicitly know that there is some code in your program which will never execute.

      2. Conditional flow changed by optimizer roughly means: the code you have written by the way you have written it would make the processor do certain condition testing, but the compiler thinks that the condition testing could also be done differently and more efficiently while the results would be the same. The compiler uses the more efficient version and warns you about it. Although I haven't tested this example, it could possibly generate such warning:

      int i;
      while (i) {
        ...nothing done with i here...

      Here since i is not modified inside the loop, the loop would either execute 0 times or loop forever. Since it is useless to test i every time (it only slows down the program), the compiler might generate code with this logic:

      if (i) {
        while (1) { ... }

      Here i would be tested only once, whereas the example code seems to test it before start of each loop. Making i volatile ("volatile int i;" instead of "int i") would make this warning go away, since volatile will tell the compiler that i could be modified so to say "externally", in an interrupt for example.

      This warning will probably not break your program (you can safely ignore it), but it usually signals that you may have written code which looks different than how it actually works.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks