This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Default values of "struct item *items[MAX_ITEMS]" array?
- From: "Andriy Korud" <a dot korud at vector dot com dot pl>
- To: "Richard Guenther" <rguenth at tat dot physik dot uni-tuebingen dot de>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Fri, 14 May 2004 10:54:38 +0200
- Subject: RE: Default values of "struct item *items[MAX_ITEMS]" array?
It seems to be compiler/optimization problem - the same kernel compiled with 2.95.4 works fine, however code compiles with 3.x fails.
Maybe compiler optimization just throws away kernel bss zeroing code?
Andriy
-----Original Message-----
From: Richard Guenther [mailto:rguenth@tat.physik.uni-tuebingen.de]
Sent: Thu 13.05.2004 20:24
To: Andriy Korud
Cc: gcc@gcc.gnu.org
Subject: Re: Default values of "struct item *items[MAX_ITEMS]" array?
Andriy Korud wrote:
> Hi, I'm trying to compile linux kernel (2.4.25) from ppc405 and have the following problem:
> After
>
> struct item *items[MAX_ITEMS];
>
> each element of items[] is initialized to 0xffffffff and following code
>
> if (items[item] != NULL) {
> items[item]->field = value;
> }
>
> gives kernel oops (as expected - trying to reference memory at address 0xffffffff).
> When I compile and run the same code on host PC - array is initialized with zeros and everything is fine.
> GCC versions tried - 3.2.3, 3.3.2, 3.3.3.
>
> The questions is: I am doing something wrong or this is a bug or feature of gcc?
gcc is probably putting the array into BSS section and the kernel fails
to zero that. You can try using -fno-zero-initialized-in-bss, but I
don't know if this affects uninitialized variables, too.
Richard.