We've run into what looks like a compiler issue dealing with a pointer dereference and a bitmask operation on the C6747.
The problem concerns dereferencing an unsigned int pointer that we use to access 32 bit words in memory. The problem is that if you dereference the pointer and apply a bit mask, the mask is not properly applied. However, if you include what should be superfluous parentheses in the C statement, the mask is applied properly. The statement that illustrates the problem is:
unsigned int *DataOut32;
*DataOut32 = *DataOut32 & 0x001FFFFF;
For example, if *DataOut32 has a value of 0x08400003, the result of the above operation came back as 0x00400003 correctly resetting bit 27 but leaving bit 22 set.
If however, you use the statement:
*DataOut32 = ( (*DataOut32) & 0x001FFFFF );
Then, with *DataOut32 initially equal to 0x08400003, the mask is correctly applied to give a result of 0x00000003. According to K&R, the precedence of operators should be such that the right side dereference of *DataOut32 occurs first, followed by the bitwise & for the mask followed by the assignment =. If the processor is truly a 32 bit machine, then this implies that CCS 3.3 does not correctly apply the C rules of operator precedence.
Yes, there is a relatively easy fix for the issue but the question remains: "How extensive is the problem in the code compilation?". Is the problem only related to bitwise operations or is it necessary to explicitly enforce operator precedence via paranthesis with other variable types?
Mike