This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fix for compilation error with gcc 3.2.3 (warning treated as error; `funaddr' might be used uninitialized)


Fix for the warning (warning treated as error)
         `funaddr' might be used uninitialized in this function'
under gcc 3.2.3. I am not sure this is the best way to fix the warning, anyway.


*** gdb/infcall.c.000   Thu Feb 14 12:04:51 2008
--- gdb/infcall.c       Thu Feb 14 12:19:07 2008
***************
*** 222,242 ****
        else
        {
          /* Handle function descriptors lacking debug info.  */
!         int found_descriptor = 0;
          if (VALUE_LVAL (function) == lval_memory)
            {
!             CORE_ADDR nfunaddr;
!             funaddr = value_as_address (value_addr (function));
!             nfunaddr = funaddr;
!             funaddr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
!                                                           funaddr,
                                                            &current_target);
!             if (funaddr != nfunaddr)
!               found_descriptor = 1;
            }
-         if (!found_descriptor)
-           /* Handle integer used as address of a function.  */
-           funaddr = (CORE_ADDR) value_as_long (function);
        }

        value_type = builtin_type_int;
--- 222,238 ----
        else
        {
          /* Handle function descriptors lacking debug info.  */
!         funaddr = (CORE_ADDR) value_as_long (function);
          if (VALUE_LVAL (function) == lval_memory)
            {
!             CORE_ADDR nfunaddr, afunaddr;
!             nfunaddr = value_as_address (value_addr (function));
!             afunaddr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
!                                                           nfunaddr,
                                                            &current_target);
!             if (afunaddr != nfunaddr)
!               funaddr = afunaddr;
            }
        }

        value_type = builtin_type_int;


gcc -c -g -O2    -I. -I.././gdb -I.././gdb/config
-DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H
-I.././gdb/../include/opcode -I.././gdb/../readline/.. -I../bfd
-I.././gdb/../bfd -I.././gdb/../include   -DMI_OUT=1 -DTUI=1  -Wall
-Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral
-Wno-unused -Wno-switch -Wno-char-subscripts -Werror infcall.c
cc1: warnings being treated as errors
infcall.c: In function `find_function_addr':
infcall.c:190: warning: `funaddr' might be used uninitialized in this function
make[2]: *** [infcall.o] Error 1

        value_type = builtin_type_int;
--- 222,239 ----
        else
        {
          /* Handle function descriptors lacking debug info.  */
!         funaddr = (CORE_ADDR) value_as_long (function);
          if (VALUE_LVAL (function) == lval_memory)
            {
!             CORE_ADDR nfunaddr, afunaddr;
!             nfunaddr = value_as_address (value_addr (function));
!             afunaddr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
!                                                           nfunaddr,
                                                            &current_target);
!             if (afunaddr != nfunaddr)
!               /* Handle integer used as address of a function.  */
!               funaddr = afunaddr;
            }
        }

        value_type = builtin_type_int;


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