W8012 Comparing signed and unsigned values (C++)

From RAD Studio
Jump to: navigation, search

Go Up to Compiler Errors And Warnings (C++) Index

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

Since the ranges of signed and unsigned types are different the result of an ordered comparison of an unsigned and a signed value might have an unexpected result.

Example:

#pragma warn +csu
boolfoo(unsigned u, int i)
{
return u < i;
}