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]

[commit] Fix compilation warning on gcc-3.4 -O2 [Re: [patch 09/15] PIE: symbol-less (exec-file only) executables]


On Fri, 15 Jan 2010 22:16:07 +0100, Stan Shebs wrote:
> My version of GCC seems not smart enough to decide if this is always
> set, and complains
> that it might be uninitialized.  Presumably harmless just to init it to 0.

Reproduced on gcc-3.4.6-11.el4_8.1.x86_64:
exec.c:678: warning: 'displacement' might be used uninitialized in this function

Checked-in.

(Not regression tested.)


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2010-01/msg00137.html

--- src/gdb/ChangeLog	2010/01/15 19:22:40	1.11259
+++ src/gdb/ChangeLog	2010/01/15 21:33:18	1.11260
@@ -1,5 +1,11 @@
 2010-01-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
+	Fix compilation warning on gcc-3.4.
+	* exec.c (print_section_info): Move the `displacement' variable
+	initialization to its declaration.
+
+2010-01-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
 	* gdb-gdb.py (StructMainTypePrettyPrinter): Fix TYPE_CODE_RANGE
 	comparison.
 
--- src/gdb/exec.c	2010/01/14 21:01:24	1.93
+++ src/gdb/exec.c	2010/01/15 21:33:18	1.94
@@ -675,7 +675,8 @@
   printf_filtered (_("file type %s.\n"), bfd_get_target (abfd));
   if (abfd == exec_bfd)
     {
-      bfd_vma displacement;
+      /* gcc-3.4 does not like the initialization in <p == t->sections_end>.  */
+      bfd_vma displacement = 0;
 
       for (p = t->sections; p < t->sections_end; p++)
 	{
@@ -694,11 +695,8 @@
 	    }
 	}
       if (p == t->sections_end)
-	{
-	  warning (_("Cannot find section for the entry point of %s.\n"),
-		   bfd_get_filename (abfd));
-	  displacement = 0;
-	}
+	warning (_("Cannot find section for the entry point of %s.\n"),
+		 bfd_get_filename (abfd));
 
       printf_filtered (_("\tEntry point: %s\n"),
 		       paddress (gdbarch, (bfd_get_start_address (abfd)


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