public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/19457] New: Warning depends on cached constant
@ 2005-01-15 12:32 reichelt at gcc dot gnu dot org
  2005-01-15 16:49 ` [Bug c++/19457] [4.0 Regression] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2005-01-15 12:32 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-01-31  1:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-15 12:32 [Bug c++/19457] New: Warning depends on cached constant reichelt at gcc dot gnu dot org
2005-01-15 16:49 ` [Bug c++/19457] [4.0 Regression] " pinskia at gcc dot gnu dot org
2005-01-15 17:07 ` schlie at comcast dot net
2005-01-15 17:17 ` schlie at comcast dot net
2005-01-15 17:36 ` schlie at comcast dot net
2005-01-15 18:10 ` schlie at comcast dot net
2005-01-18  1:02 ` pinskia at gcc dot gnu dot org
2005-01-29  2:46 ` mmitchel at gcc dot gnu dot org
2005-01-31  1:17 ` cvs-commit at gcc dot gnu dot org
2005-01-31  1:22 ` mmitchel at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).