This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc 4.3.0, -Wconversion: assignment-by operators for shorter types
- From: "Manuel López-Ibáñez" <lopezibanez at gmail dot com>
- To: "Andriy Gapon" <avg at icyb dot net dot ua>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 27 May 2008 12:50:55 +0200
- Subject: Re: gcc 4.3.0, -Wconversion: assignment-by operators for shorter types
- References: <483AF557.8050603@icyb.net.ua>
Please, open a bug report: http://gcc.gnu.org/bugzilla/
Thanks,
Manuel.
2008/5/26 Andriy Gapon <avg@icyb.net.ua>:
>
> 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
>