Daniel Lundin

C5906: Subtraction with zero

Discussion created by Daniel Lundin on Feb 14, 2007
Latest reply on Feb 15, 2007 by kef
Using CW3.1 for HCS12 DG128.

I get a strange warning "C5906: Subtraction with zero" which I don't understand where it comes from. I have the following code:

(Gah, it is hopeless to post any kind of source code on this site, please check attached file instead.)

The code seems to work, but I like to know where that warning came from. According to the helpfile you may get it from the tree optimizer:

"This message may be generated during tree optimizations (Option -Ont to switch it off)."

So I disabled that one and the warning disappeared. I still don't understand why I got it, there seems to be nothing wrong with the code and if I look at the asm code, no subtraction with zero is taking place. Everything looks ok even though the subraction is done inside the if-condition rather than at the line where the value is assigned:

07ba ec8f LDD 15,SP
07bc 830300 SUBD #768
07bf 8c001f CPD #31
07c2 226a BHI *+108 ;abs = 082e

Any ideas?