[Bug c/61029] Bogus conversion warnings are issued on a sign change "a = -a;" operation
manu at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu May 1 18:07:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61029
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
Resolution|INVALID |DUPLICATE
--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Dmitry Chichkov from comment #2)
> Results in:
> -32768
> -32768
>
> But still, it doesn't seem right that code like "a = -a;" has to be writted
> as a "a = static_cast<short int>(-a);" to avoid conversion warnings. That
> kills readability while not adding any value.
Also, the issue above is independent of the implicit conversion, it happens
also for int and INT_MIN. Unfortunately, there is some controversy among GCC
developers about whether this is the desired behavior of the warning or not. A
solution that may be accepted by all is to have a new warning option that does
not warn for cases where the target type is the same as the operand type. But
someone needs to implement this solution.
*** This bug has been marked as a duplicate of bug 40752 ***
More information about the Gcc-bugs
mailing list