Bug 30086 - Initialize struct to avoid warnings shouldn't be needed
Summary: Initialize struct to avoid warnings shouldn't be needed
Status: RESOLVED DUPLICATE of bug 5035
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-06 16:04 UTC by Markus Deuling
Modified: 2006-12-13 07:31 UTC (History)
10 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Source file mentioned in the description (8.43 KB, text/x-csrc)
2006-12-07 09:54 UTC, Markus Deuling
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Deuling 2006-12-06 16:04:48 UTC
When compiling GDB 6.5.90 on x86 (FC5) GCC gives following warning. So it is needed to initialize tmp_obstack to avoid this warning. This isn't necessary and GCC should detect this.

/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c: In function 
'pascal_object_print_value_fields':
/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c:756: warning: 'tmp_obstack.alloc_failed' may be used uninitialized in this function
/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c:756: warning: 'tmp_obstack.maybe_empty_object' may be used uninitialized in this function
/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c:756: warning: 'tmp_obstack.use_extra_arg' may be used uninitialized in this function
/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c:756: warning: 'tmp_obstack.extra_arg' may be used uninitialized in this function
/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c:756: warning: 'tmp_obstack.freefun' may be used uninitialized in this function
/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c:756: warning: 'tmp_obstack.chunkfun' may be used uninitialized in this function
/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c:756: warning: 'tmp_obstack.alignment_mask' may be used uninitialized in this function
/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c:756: warning: 'tmp_obstack.temp' may be used uninitialized in this function
/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c:756: warning: 'tmp_obstack.chunk_limit' may be used uninitialized in this function
/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c:756: warning: 'tmp_obstack.next_free' may be used uninitialized in this function
/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c:756: warning: 'tmp_obstack.object_base' may be used uninitialized in this function
/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c:756: warning: 'tmp_obstack.chunk' may be used uninitialized in this function
/home/user/gdb/6.5.90/gdb-6.5.90/gdb/p-valprint.c:756: warning: 'tmp_obstack.chunk_size' may be used uninitialized in this function
make[2]: *** [p-valprint.o] Error 1
make[2]: Leaving directory `/home/user/gdb/6.5.90/gdb-6.5.90/build_werr/gdb'
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory `/home/user/gdb/6.5.90/gdb-6.5.90/build_werr'
make: *** [all] Error 2
Comment 1 Andrew Pinski 2006-12-06 23:14:00 UTC
Depends how the source looks, it might be actually used uninitialized which means the code is undefined anyways.
Can you attach the preprocessed source?

I have seen stuff like:

struct a{int t; int t1};

void f(struct a);

void g(void)
{
  struct a b;
  b.t = 1;
  f(b);
}
(maybe a little more complex but you get the idea).
How does GCC know that not all the elements of b are not used.
Comment 2 Markus Deuling 2006-12-07 09:54:30 UTC
Created attachment 12764 [details]
Source file mentioned in the description
Comment 3 Markus Deuling 2006-12-07 09:55:33 UTC
I attached the file. Its from GDB 6.5.90 release.
Comment 4 Andrew Pinski 2006-12-13 07:31:23 UTC
The problem here is the same as PR 5035 really, just this case has structs and the other case is for scalars but the problems are the same.

*** This bug has been marked as a duplicate of 5035 ***