We think we have found a bug with code warrior V2.10 when compiling for the MPC5534. The bug is that sometimes a member variable bool of a class will be set to a value of 0xFF instead of 0x01. Attached is example code for how to reproduce the problem. The problem occurs in the constuctor of Test2 when it is assigning a value into bad_val as a a result of anding itself with success.
Test2 Constructor Dissassembly
48 00 se_li r0,0
7c 00 00 34 cntlzw r0,r0
00 c4 se_extzb r4
68 50 se_srwi r0,5
46 40 se_and r0,r4
7c 80 00 d0 neg r4,r0
44 40 se_or r0,r4 // Here is the problem r0 is now 0xFFFFFFFF
66 00 se_btsti r0,0
48 14 se_li r4,1
90 43 se_stb r4,0(r3)
91 03 se_stb r0,1(r3) // And bad_val gets assigned with 0xFF
e6 06 se_beq 3bca0 <__ct__5Test2Fb+0x26>
71 04 e0 86 e_lis r8,8326
54 88 1c c0 e_stw r4,7360(r8)
e8 06 se_b 3bcaa <__ct__5Test2Fb+0x30>
71 04 e0 86 e_lis r8,8326
48 20 se_li r0,2
54 08 1c c0 e_stw r0,7360(r8)
00 04 se_blr
I tried to reproduce the problem for you in an example project. Unfortunately the previous person who set this up is using a perl script to pass in all the compiler options to the IDE. My problem at the moment is can't seem to line all of them up to whats in the software. But I have it close and when it compiles this code it produces something very similar. Plus it has an extra instruction before storing the value in to bad_val that makes it equal 1 instead of 0xFF and it makes everything work. Hopefully this missing instruction can act like a clue for you?
48 15 se_li r5,1
90 53 se_stb r5,0(r3)
48 00 se_li r0,0
00 c4 se_extzb r4
7c 00 00 34 cntlzw r0,r0
68 50 se_srwi r0,5
46 40 se_and r0,r4
7c 80 00 d0 neg r4,r0
44 40 se_or r0,r4
69 f0 se_srwi r0,31 // Shifts R0 to be 1 and this is what gets written in to bad_val
91 03 se_stb r0,1(r3)
22 00 se_cmpli r0,1
e2 06 se_bne 2226 <__ct__5Test2Fb+0x28>
71 08 e0 01 e_lis r8,16385
54 a8 f0 00 e_stw r5,-4096(r8)
e8 06 se_b 2230 <__ct__5Test2Fb+0x32>
48 20 se_li r0,2
71 08 e0 01 e_lis r8,16385
54 08 f0 00 e_stw r0,-4096(r8)
00 04 se_blr
If there is a document that talks about how to call the IDE from the command line for setting these compiler options, could you please share it with me? It would help line up some of the compiler options.
Attached Files:
* test.cpp - Contains the relevant constructor that is producing the bad code
* test.h - Header file for it.
* main.cpp - Should be able to copy this in to a fresh project
* test.mcp - My current project file with my guesses as to what some of the compiler config is.
* MPC5534.lcf - A modified linker file I was using
If there is any other info you need please let me know.
Also could I know the conditions in which the error occurs to safely work around it?