This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -fzero-initialized-in-bss
(Sorry my first attempt bounced....)
> We're having some obscure failures with code containing things like
>
> static struct something *ptr = 0;
>
> The variable ptr is placed in .bss (.sbss with -Os) and allocated via
> .zero. Running the program under gdb shows the value as -1. If I
> recompile with -fno-zero-initialized-in-bss, it goes to .data, the
> value appears as 0, and the program runs as expected.
Can you create a reduced testcase which demonstrates the problem?
http://gcc.gnu.org/bugs.html#report
E.g. what do you get when you compile and run the following program?
extern int printf (const char *, ...);
extern void abort(void);
int main(void)
{
static struct something *ptr1, *ptr2 = 0;
printf ("%p %p\n", ptr1, ptr2);
if (ptr1 != ptr2)
abort();
return 0;
}
It should output "0 0".
Thanks,
--Kaveh
--
Kaveh R. Ghazi ghazi@caip.rutgers.edu