This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
gcc 4.3.0, -Wconversion: assignment-by operators for shorter types
- From: Andriy Gapon <avg at icyb dot net dot ua>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 26 May 2008 20:37:27 +0300
- Subject: 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