This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/23608] -Wsign-compare and const propagation
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Aug 2005 23:10:38 -0000
- Subject: [Bug c++/23608] -Wsign-compare and const propagation
- References: <20050829023010.23608.br1@internet.com.uy>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bangerth at dealii dot org 2005-08-29 23:10 -------
What Andrew is trying to say is that in C, even variables that are marked
'const' can be modified. Thus, the compiler can't (naively, i.e. without
using flow analysis) determine that 'i' or 'ic' have the value 5, and
therefore warn that there is a comparison between signed and unsigned.
However, in the last line, the compiler knows the value that is being
compared to 5u and sees that nothing bad can happen here. It therefore
does not warn.
In C++, the situation is different, since const variables can't be changed.
The compiler could therefore be able to determine that the second comparison
does not warrant a warning. This notwithstanding, the compiler doesn't do
this right now.
As annoying as this is, I don't consider this a bug. It may be classified
as an enhancement, though, if someone wants to make this warning contigent
upon the availability of forward propagation of values. General consensus
has been, however, not to do this.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Priority|P2 |P3
Last reconfirmed|0000-00-00 00:00:00 |2005-08-29 23:10:37
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23608