Laurent Cremmer

CodeWarrior for ColdFire 7.1 Compiler Bug ?

Discussion created by Laurent Cremmer on Sep 10, 2008
Latest reply on Sep 12, 2008 by Rich Testardi
Using CodeWarrior 7.0, compiling the following C code :

int a = -10003
a = -10002 - a

will produce the following assembly code

;
;    int a = -10003
;
0x0000003C  0x717CD8ED               mvs.w    #-10003,d0
0x00000040  0x2D40FFB0               move.l   d0,-80(a6)
;
;     a = -10002 - a;
;
0x00000044  0x717CD8EE               mvs.w    #-10002,d0
0x00000048  0x90AEFFB0               sub.l    -80(a6),d0
0x0000004C  0x2D40FFB0               move.l   d0,-80(a6)

that correctly computes the result and stores 1 back in a.

Whereas CodeWarrior 7.1.1  happily compiles that down to
;
;    int a = -10003
;
0x0000003C  0x717CD8ED               mvs.w    #-10003,d0
0x00000040  0x2D40FFB0               move.l   d0,-80(a6)
;
;     a = -10002 - a;
;
0x00000044  0x737CD8EE               mvs.w    #-10002,d1
0x00000048  0x93AEFFB0               sub.l    d1,-80(a6)

which is obviously wrong as it swaps the order of the subtract operands, storing back -1 (!!!!!) in a

As anyone noticed that bug before ? Any idea how such a basic bug could end up in 7.1.1 ?

Regards,
L.


Message Edited by laurent@mode on 2008-09-10 04:25 PM

Message Edited by laurent@mode on 2008-09-10 04:26 PM

Outcomes