#745 Detected Bug in preprocessor

closed-duplicate
nobody
None
5
2013-05-25
2004-04-22
David
No

Hi and sorry for my English.
I think that i have discovered a bug in preprocessor.
This bug don't allow to use more than only one "if"
sentence in macros. When we use several "if"
sentences, "if ... else" sentences or "if.. else if ..."
sentences the preprocessor generates a
warning: "unreachable code" in the line of the main
program where is the call to the macro.

I attach a simply program that defines a macro that
uses an "if .. else" sentence, and the main function call
it.

I'm using the latest version of sdcc (2.4.0)

compile the file:> sdcc -c bug.c
it generates the warning "unreachable code" in the line
where the main function call the macro that uses
the "if .. else" sentence.

Thanks.

David Martinez Martinez
mail: davbom@yahoo.com
dmm@gbt.tfo.upm.es

Discussion

  • David

    David - 2004-04-22

    Simply file containing a macro and main function

     
  • Erik Petrich

    Erik Petrich - 2004-04-22
    • status: open --> closed-duplicate
     
  • Erik Petrich

    Erik Petrich - 2004-04-22
    • milestone: --> non_bugs
     
  • Erik Petrich

    Erik Petrich - 2004-04-22

    Logged In: YES
    user_id=635249

    The compiler generates the correct code for this. The
    warning is also correct; there is unreachable code. If you
    prefer that the compiler not generate the warning, you can
    recode the macro as a conditional expression:

    #define WDT_ENABLE(bool) (bool ? (WDT|=0x08) : (WDT|=0x10,
    WDT&=~0x08))

     

Log in to post a comment.