|
|||||||||||
|
Technical Support Support Resources
Product Information |
ARMCLANG: Wrong result from (int&mask)<<shift when compiling with -O0Information in this knowledgebase article applies to:
QUESTIONWhen compiling the following code snippet using Arm Compiler 6.11 with the optimization level -O0, unsigned int fn(unsigned int arg) {
return (arg & 0x0000FF00) << 8;
}
int main () {
printf("0x%08X\n", fn(0x12345678));
}
I got the wrong result 0x00005600, instead of the correct result 0x00560000. How can I resolve this issue? ANSWERThis is, unfortunately, a known bug in the Arm Compiler 6.11 to build code above when the optimization -O0 is used. RESOLUTIONUsing Arm Compiler 6.11 with other optimization levels, such as -O1 etc. can resolve this issue. The operation e.g. (int & mask) >> shift, is not affected by this bug. The older versions of the Arm Compiler 6, such as 6.10 etc. are not affected either. This bug is fixed since the release of Arm Compiler 6.12. Last Reviewed: Wednesday, November 4, 2020 | ||||||||||
|
|||||||||||
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.