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] |
Please, open a bug report: http://gcc.gnu.org/bugzilla/
short_x += short_y; short_x = short_x + short_y;
int_x += int_y; int_x = int_x + int_y;
return 0; } **********************
$ g++ -dumpversion 4.3.0
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
-- Andriy Gapon
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |