This is the mail archive of the gcc@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: format argument warnings


Sorry if this only delays the patch approval but may I suggest a different
patch. It seems slightly better to avoid explicit casts.

Indeed, this is the offending statement

      ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, FDE_LABEL, for_eh + i * 2);

Trouble is caused by local variable i which is declared unsigned long int.

However, it is only used as the following loop counter:
      for (i = 0; i < fde_table_in_use; ++i)

fde_table_in_use is declared as:
static unsigned fde_table_in_use;

for_eh is declared as int.                                                    
     
so its safe to make `i' an unsigned int.
As is done in the following patch
which is lifted out of

http://gcc.gnu.org/ml/gcc-patches/2001-06/msg01425.html

Had I known that it already caused this amount of discussion I wouldn't have
posted it as 'obvious'....

jan


Index: gcc/gcc/dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.277
diff -c -3 -p -r1.277 dwarf2out.c
*** dwarf2out.c	2001/06/10 13:47:55	1.277
--- dwarf2out.c	2001/06/24 15:34:37
*************** static void
*** 1718,1724 ****
  output_call_frame_info (for_eh)
       int for_eh;
  {
!   register unsigned long i;
    register dw_fde_ref fde;
    register dw_cfi_ref cfi;
    char l1[20], l2[20];
--- 1718,1724 ----
  output_call_frame_info (for_eh)
       int for_eh;
  {
!   register unsigned int i;
    register dw_fde_ref fde;
    register dw_cfi_ref cfi;
    char l1[20], l2[20];


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