2015-12-22 07:42 PM
Hi all
Cosmic compiler: Parser V4.11.4 - 12 Aug 2015, Generator (Limited) V4.4.3 - 13 Oct 2015 Optimizer V4.4.3 - 13 Oct 2015 Consider the attached test code - testbug.c line 17 isCW = !isCW ; // generates incorrect code using cpl instruction, with or with optimization The compiler does not differentiate logical not '!' construct and complement '~' construct, and treats them the same here. when isCW is true = 0x01, !isCW using cpl instruction causes isCW becomes 0xfe. subsequent test on isCW at line 18 always result in true and causes line 19 always execute. The correct code generation should use bcpl instruction instead. The temporary fix can be: 1. use static or global variable for isCW 2. use the construct isCW ^= 1 ; // knowing that it is just the lsb of a byte. both are not a very good fix. An alternate good fix can be shown in mod-testbug.c. By adding another initialized dummy boolean variable. This way the compiler will pack the booleans into a byte, forcing the compiler to interpret each boolean correctly. Calvin #bug #cosmic2015-12-30 12:04 AM
Hello,
this problem is confirmed and will be fixed asap. For those who might be worried about running into it in their application, please note that it happens only when using logical not on 1 boolean variable (if there is more than one variable the problem does not happen) as a local (globals are OK). Regards, Luca (Cosmic)