[LLVMbugs] [Bug 18691] No -Wtautological-constant-out-of-range-compare warning
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Dec 28 12:56:19 PST 2014
http://llvm.org/bugs/show_bug.cgi?id=18691
Chengnian Sun <chengniansun at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |---
--- Comment #2 from Chengnian Sun <chengniansun at gmail.com> ---
I found another test case. I am not sure whether I should open another report,
so just reopen this one.
Wtautological-constant-out-of-range-compare does not warn on the following
case, which has a type conversion from bool to short type. If I remove the type
cast, Clang warns.
/////////////////////////////////////////////////////////
// test case on which clang does not warn
/////////////////////////////////////////////////////////
$: cat t.c
int f(int a) {
return 999 != (short)(a == 1);
}
$:
$: clang-trunk -Weverything -c t.c
t.c:1:5: warning: no previous prototype for function 'f' [-Wmissing-prototypes]
int f(int a) {
^
1 warning generated.
$:
$: gcc-trunk -c t.c -Wall
t.c: In function ‘f’:
t.c:2:14: warning: comparison of constant ‘999’ with boolean expression is
always true [-Wbool-compare]
return 999 != (short)(a == 1);
^
$:
/////////////////////////////////////////////////////////
// clang warns on the following case
/////////////////////////////////////////////////////////
$: cat t.c
int f(int a) {
return 999 != (a == 1);
}
$:
$: clang-trunk -Weverything -c t.c
t.c:1:5: warning: no previous prototype for function 'f' [-Wmissing-prototypes]
int f(int a) {
^
t.c:2:14: warning: comparison of constant 999 with boolean expression is always
true [-Wtautological-constant-out-of-range-compare]
return 999 != (a == 1);
~~~ ^ ~~~~~~~~
2 warnings generated.
$:
$: gcc-trunk -c t.c -Wall
t.c: In function ‘f’:
t.c:2:14: warning: comparison of constant ‘999’ with boolean expression is
always true [-Wbool-compare]
return 999 != (a == 1);
^
$:
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141228/535c3dd4/attachment.html>
More information about the llvm-bugs
mailing list