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

gcc 4.3.0, -Wconversion: assignment-by operators for shorter types


If I write something like the following:
uint8_t x;
uint8_t y;
x ^= y;

and compile with gcc 4.3.0 with  -Wconversion option, then I get the
following warning:
warning: conversion to âunsigned charâ from âintâ may alter its value
[-Wconversion]

While technically this warning is correct (because x and y are
implicitly advanced to "int"before actual xor operation), it seems that
it doesn't make much practical sense.

I think that this applies to all "assignment-by" operators working on
types shorter than int.

OTOH, proper implementation should be smart enough to warn about the
following:
uint8_t x;
uint16_t y;
x ^= y;


-- 
Andriy Gapon


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