FreeBSD の LLVM で C 言語の整数型リテラル値の論理和を試す ― 2018年09月23日 12時33分59秒
コードは簡潔に。
今回は FreeBSD 11.2-RELEASE の LLVM 6.0.0 を使って実験。
freebsd% cat logical-and-int.c
int main()
{
return 1 && 2;
}
定数の論理和を行うと警告が出された。論理積 の & と間違えたのではとの、考察のようだ。確かに、簡単な論理和をわざわざ定数で求める理由はたいしてない。
freebsd% cc logical-and-int.c
logical-and-int.c:3:14: warning: use of logical '&&' with constant operand
[-Wconstant-logical-operand]
return 1 && 2;
^ ~
logical-and-int.c:3:14: note: use '&' for a bitwise operation
return 1 && 2;
^~
&
logical-and-int.c:3:14: note: remove constant to silence this warning
return 1 && 2;
~^~~~
1 warning generated.
次回。
最近のコメント