この製品は符号付きプリミティブを使用し、符号なしプリミティブへのキャストを実行します。符号付きプリミティブの値が符号なしプリミティブを使用して表現できない場合、予期しない値が生成される可能性があります。
符号付き数値と符号なし数値の間の暗黙のキャストに頼るのは危険である。なぜなら、その結果が予期せぬ値をとり、プログラムによる仮定に反する可能性があるからである。
関数が失敗を示すために負の値を返すことはよくあります。関数の結果をサイズ・パラメータとして使用する場合、負の戻り値を使用すると予期せぬ結果を招くことがあります。例えば、標準的なメモリコピー関数やアロケーション関数に負のサイズ値を渡すと、暗黙のうちに大きな符号なし値にキャストされてしまいます。これは、バッファ・オーバーフローやアンダーフローを引き起こす可能性があります。
The product uses a signed primitive and performs a cast to an unsigned primitive, which can produce an unexpected value if the value of the signed primitive can not be represented using an unsigned primitive.
It is dangerous to rely on implicit casts between signed and unsigned numbers because the result can take on an unexpected value and violate assumptions made by the program.
Often, functions will return negative values to indicate a failure. When the result of a function is to be used as a size parameter, using these negative return values can have unexpected results. For example, if negative size values are passed to the standard memory copy or allocation functions they will be implicitly cast to a large unsigned value. This may lead to an exploitable buffer overflow or underflow condition.