This is the mail archive of the gcc-bugs@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]

[Bug c++/34198] -Wconversion gives apparent erroneous warning with g++ 4.3-20071109



------- Comment #3 from fang at csl dot cornell dot edu  2007-11-22 21:52 -------
I'm having some issues with this as well (same snapshot):

some more tests:

void f(const unsigned char b)
{
 unsigned char c = static_cast<unsigned char>(b & 0xff);
 unsigned char d = (unsigned char)(b & 0xff);
 char e = static_cast<char>(b & 0xff);
 char f = char(b & 0xff);
}

pr34198.cc:4: error: conversion to 'unsigned char' from 'int' may alter its
value
pr34198.cc:5: error: conversion to 'unsigned char' from 'int' may alter its
value
pr34198.cc:6: error: conversion to 'unsigned char' from 'int' may alter its
value
pr34198.cc:7: error: conversion to 'unsigned char' from 'int' may alter its
value

I'm trying to understand all the reasonings: http://gcc.gnu.org/wiki/Wcoercion
IMHO, the explicit casts (static_cast or function-style) should suppress the
warnings.


-- 

fang at csl dot cornell dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fang at csl dot cornell dot
                   |                            |edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34198


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