[Bug c/63710] Incorrect column number for -Wconversion
chengniansun at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Nov 7 19:02:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63710
--- Comment #1 from Chengnian Sun <chengniansun at gmail dot com> ---
I find the following test case, which seems related to this bug. The locations
of both warnings point to the condition instead of the expressions which
require conversion.
$: cat t.c
unsigned f(long l, char c) {
return l ? l : c;
}
$:
$: gcc-trunk -Wconversion t.c -c
t.c: In function ‘f’:
t.c:2:10: warning: conversion to ‘unsigned int’ from ‘char’ may change the sign
of the result [-Wsign-conversion]
return l ? l : c;
^
t.c:2:10: warning: conversion to ‘unsigned int’ from ‘long int’ may alter its
value [-Wconversion]
$:
$:
$: clang-trunk -Wconversion t.c -c
t.c:2:18: warning: operand of ? changes signedness: 'char' to 'unsigned int'
[-Wsign-conversion]
return l ? l : c;
~~~~~~ ^
t.c:2:14: warning: implicit conversion loses integer precision: 'long' to
'unsigned int' [-Wshorten-64-to-32]
return l ? l : c;
~~~~~~ ^
2 warnings generated.
More information about the Gcc-bugs
mailing list