-Wconversion bug in g++-4.3?

Tom Browder tom.browder@gmail.com
Tue Nov 20 06:55:00 GMT 2007


(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



More information about the Gcc-help mailing list