We found a bug in the C/C++ optimizer in CodeWarrior R5 on the
Mac. This bug is probably present in the Windows version as well
since it's in the compiler, which is probably very similar on both
platforms. Turning on the common sub-expression elimination
optimization can cause the compiler to generate incorrect code.
Scenario: Create a new empty project with a single file containing the following code:
typedef
struct
{
long foo1, foo2, foo3, foo4;
}
FooType;
FooType
*FooPtrs[4], Foo;
static void
TestCSE(unsigned short i)
{
Foo
= *(FooPtrs[i]);
FooPtrs[i]->foo1 = 0;
}
Set the target settings as follows:
Scenario: Create a new empty project with a single file containing the following code:
Set the target settings as follows:
Leave all other target settings at their default values. Now make the project. You'll get a link error since there is no 'main' routine. Ignore it. Now disassemble the program. You'll get:
^----------------------should be move.l
0000001C:
20D9 move.l
(a1)+,(a0)+
0000001E:
20D9 move.l
(a1)+,(a0)+
00000020:
20D9 move.l
(a1)+,(a0)+
00000022:
20D9 move.l
(a1)+,(a0)+
00000024:
4292 clr.l
(a2)
00000026:
245F movea.l (a7)+,a2
00000028:
4E5E unlk
a6
0000002A:
4E75 rts
The result of this error is that the source for the structure copy is incorrect.
The result of this error is that the source for the structure copy is incorrect.
-
Danny Epstein * mailto:[EMAIL PROTECTED]
Applied Thought Corporation * http://www.appliedthought.com
Flytrap for PalmOS * http://www.appliedthought.com/flytrap
Danny Epstein * mailto:[EMAIL PROTECTED]
Applied Thought Corporation * http://www.appliedthought.com
Flytrap for PalmOS * http://www.appliedthought.com/flytrap
