This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/34389] New: -Wconversion produces wrong warning
- From: "Raimund dot Merkert at baesystems dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Dec 2007 04:15:19 -0000
- Subject: [Bug c/34389] New: -Wconversion produces wrong warning
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
If compiled with gcc -c -Wconversion the following code produces the warning:
test.c:7: warning: conversion to ?short int? from ?int? may alter its value
but if -DNO_WARNING is turned on it doesn't even though it should be same code.
cat > test.c <<EOF
short mask(short x)
{
#if NO_WARNING
short y = 0x7fff;
return x&y;
#else
return x & (short)0x7fff;
#endif
}
EOF
On a side node, I think it would be better to also change the warning to :
"conversion from 'int' to 'short int' may alter its value", which i find easier
to read.
--
Summary: -Wconversion produces wrong warning
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Raimund dot Merkert at baesystems dot com
GCC target triplet: gcc (GCC) 4.3.0 20071130 (experimental)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34389