This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [980307]: Warning patches #1/5 - signed vs. unsigned.


On Wed, 11 March 1998, 19:48:51, ghazi@caip.rutgers.edu wrote:

 >  > From: Jim Wilson <wilson@cygnus.com>
 >  > 
 >  > This is OK to install.

Done.

 >  > 
 >  > I see that you have an enquire.c change.  The enquire.c copyright requires
 >  > that we document all changes near the top of the file.  Please add such a
 >  > change similar to the existing changes.

Done.

 >  > 
 >  > 	In dwarf2out.c (reg_save) I added a FIXME comment to highlight a
 >  > 	comparison of an unsigned variable with -1 in an if statement!
 >  > 
 >  > 	!   if (sreg == -1)	/* FIXME: How can this be -1? It is an unsigned!  */
 >  > 
 >  > 	Can someone who's more experienced with this particular code take a look?
 >  > 
 >  > The code is correct.  -1 is used to indicate that the value isn't a register
 >  > number.  The -1 just gets casted to unsigned, and becomes UINT_MAX.  It may
 >  > not be pretty, but I think it should always work.
 >  > Jim
 > 
 > 	In that case, when Manfred checks it in, the -1 should be
 > explicitly cast to unsigned (to silence the warning) with a comment
 > stuck on top of it (eg, your words above.)  Yes?

I changed it this way:

  /* The following comparison is correct. -1 is used to indicate that
     the value isn't a register number.  */
  if (sreg == (unsigned int) -1)

manfred


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]