This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/19457] New: Warning depends on cached constant
- From: "reichelt at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Jan 2005 12:32:35 -0000
- Subject: [Bug c++/19457] New: Warning depends on cached constant
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Mainline's C++ frontend warns about the following code snippet:
======================
int i=-1;
unsigned int j= ~0;
======================
warn.cc:2: warning: converting of negative value '-0x000000001' to
'unsigned int'
The strange thing is that the warning disappears if I comment out the
unrelated first line or change the value for "i" to "-2". Looks like
the cached constant determines the type of the new constant.
I'd expect "~0" to be signed and "~0u" to be unsigned, so I think the
warning is correct, but I'm not sure.
But in either case, the warning should not depend on some cached constant.
Btw, what about the constant 0xffffffff? Should a warning appear when
is's assigned to a signed or an unsigned int?
--
Summary: Warning depends on cached constant
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: reichelt at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19457