This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CARM 1.3 bug?

I've port C source from C51 to CARM
but CARM compiler seem has bug in comparison.

#include <lpc210x.h>

//DKARM 1.3h
//----------
//AA MACRO ASSEMBLER V0.10a
//CA ARM COMPILER V0.10a
//LA ARM LINKER/LOCATER V0.10c

unsigned char test(void) {
    return(0xEE);
}

void main(void) {
    unsigned char K;
    K=test();
    if ((K&0x0F)!=0x0F) {
        //0xEE&0x0F=>0x0E
        //0x0E!=0x0F
        //but this block don't enter
        while (1);
    }
    else {
        while (1);
    }
}

Parents
  • Smells of optimisation to me!

    You have an 'if' statement where the content of both the 'then' and 'else' clauses are identical!
    Thus the operation of your code is unaffected if the compiler simply replaces the whole thing with:

            while (1);
    
    Could this be what's happening?

Reply
  • Smells of optimisation to me!

    You have an 'if' statement where the content of both the 'then' and 'else' clauses are identical!
    Thus the operation of your code is unaffected if the compiler simply replaces the whole thing with:

            while (1);
    
    Could this be what's happening?

Children
No data