Avoid "may be used uninitialized" warning
authorYao Qi <yao@codesourcery.com>
Sun, 8 Dec 2013 02:34:34 +0000 (10:34 +0800)
committerYao Qi <yao@codesourcery.com>
Sun, 8 Dec 2013 02:34:34 +0000 (10:34 +0800)
Hi,
I see such warning below on one compiler I am using.

cc1: warnings being treated as errors
../../workspace/gdb/stack.c: In function 'frame_info':
../../workspace/gdb/stack.c:1519:20: error: 'caller_pc' may be used uninitialized in this function

Go through the gdb-patches archives and find the "canonical" way to
fix this warning is to initialize the variable.

gdb:

2013-12-08  Yao Qi  <yao@codesourcery.com>

* stack.c (frame_info): Initialize variable caller_pc.

gdb/ChangeLog
gdb/stack.c

index 474839254dedf6e23c18e7b80ebdbb2629d783d0..252aa697b697679a9d7e46ccc42e85875e12879d 100644 (file)
@@ -1,3 +1,7 @@
+2013-12-08  Yao Qi  <yao@codesourcery.com>
+
+       * stack.c (frame_info): Initialize variable caller_pc.
+
 2013-12-06  Pedro Alves  <palves@redhat.com>
 
        * frame.c (enum cached_copy_status): New enum.
index 848bcb0a2626c81d69a10bd03801549d3fdc2e1e..f45bb8050a45f5acac1913dfd4dbd58e58951e18 100644 (file)
@@ -1407,7 +1407,8 @@ frame_info (char *addr_exp, int from_tty)
   struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
   CORE_ADDR frame_pc;
   int frame_pc_p;
-  CORE_ADDR caller_pc;
+  /* Initialize it to avoid "may be used uninitialized" warning.  */
+  CORE_ADDR caller_pc = 0;
   volatile struct gdb_exception ex;
 
   fi = parse_frame_specification_1 (addr_exp, "No stack.", &selected_frame_p);