【ISO/ANSI/JIS】 C言語なら俺に聞け! Part 130
■ このスレッドは過去ログ倉庫に格納されています
0175デフォルトの名無しさん
2006/10/20(金) 02:43:31"The result of the unary - operator is the negative of its (promoted) operand. The integer
promotions are performed on the operand, and the result has the promoted type."
そこで質問ですが、 -1u という式の型と値はそれぞれ何になるのでしょうか?
型は 1u が unsigned int で、整数拡張しても unsigned int のままなので
やっぱり unsigned int だと思うのですが、値のほうは符号無し型に対して
"negative" と言われても定義できないような気がします。もしや未定義動作でしょうか?
未定義動作ってことになると、 -sizeof(...) なんてコードでうっかり踏んでそう。
■ このスレッドは過去ログ倉庫に格納されています