ARM Technical Support Knowledge Articles

WARNING #61-D: INTEGER OPERATION RESULT IS OUT OF RANGE

Applies to: RealView C Compiler

Answer


Information in this article applies to:


QUESTION

I have written the following code:

unsigned int i;
i = (u32)(3<<30);

However this generates a warning:

warning:  #61-D: integer operation result is out of range

Can I avoid this warning somehow?

ANSWER

The compiler overflow warning is correct, because the expression 3<<30 represents a signed int. To avoid the warning, explicitly define the constant 3 as an unsigned value using the U postfix. For example:

unsigned int i;
i = (u32)(3U<<30);

MORE INFORMATION

SEE ALSO

Article last edited on: 2010-03-23 09:05:26

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential