This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
-Wconversion bug in g++-4.3?
- From: "Tom Browder" <tom dot browder at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 19 Nov 2007 14:11:43 -0600
- Subject: -Wconversion bug in g++-4.3?
(Excuse the previous msg--lost control of the key board.)
Consider the following code:
f.cc ==>
void f(const unsigned char b)
{
unsigned char c = static_cast<unsigned char>(b & 0xff);
}
<== f.cc
Compile with g++ 4.1.2:
$ g++-4.3-20071109 -c f.c -Wconversion
$
Note no warnings.
Compile with g++ 4.3-20071109:
$ g++-4.3-20071109 -c f.c -Wconversion
f.cc: In function 'void f(unsigned char)':
f.cc:3: warning: conversion to 'unsigned char' from 'int' may alter its value
Is this a legitimate warning or a bug? If so, is there anything to be
done to eliminate the warning while retaining "-Wconversion"?
Thanks.
-Tom
Tom Browder
Niceville, Florida
USA