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