This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

-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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]