This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/61029] Bogus conversion warnings are issued on a sign change "a = -a;" operation
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 01 May 2014 18:07:15 +0000
- Subject: [Bug c/61029] Bogus conversion warnings are issued on a sign change "a = -a;" operation
- Auto-submitted: auto-generated
- References: <bug-61029-4 at http dot gcc dot gnu dot org/bugzilla/>
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 ***