RAD Studio
ContentsIndex
PreviousUpNext
W8068: Constant out of range in comparison

(Command-line option to suppress warning: -w-rng) 

Your source file includes a comparison involving a constant sub-expression that was outside the range allowed by the other sub-expression's type. 

For example, comparing an unsigned quantity to -1 makes no sense. 

To get an unsigned constant greater than 32,767 (in decimal), you should either

  • cast the constant to unsigned--for example, (unsigned) 65535, or
  • append a letter u or U to the constant--for example, 65535u.
Whenever this message is issued, the compiler still generates code to do the comparison. 

If this code ends up always giving the same result (such as comparing a char expression to 4000), the code will still perform the test.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!