Bug#228506: gcc-3.3: initalizing to zero equals uninitialised
Package: gcc-3.3
Version: 1:3.3.3-0pre2
Severity: important
If I have a static variable initialized to 0 it ends up as uninitialized.
See below. Compiling this with gcc-3.2 yields a correct result.
$ cat test.c
#include <stdio.h>
int main(void) {
static int a;
static int b = 0;
static int c = 7;
printf("a: %d, b: %d, c: %d\n", a, b, c);
}
$ gcc --version
gcc (GCC) 3.3.3 20040110 (prerelease) (Debian)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gcc -S test.c
$ cat test.s
[...]
[static int a gets initialized, this one is uninitialized]
.local a.0
.comm a.0,4,4
[static int b gets initialized, this one is also uninitialized]
.local b.1
.comm b.1,4,4
[static int c is placed in .data-section and initialized to 7]
.data
.align 4
.type c.2, @object
.size c.2, 4
c.2:
.long 7
[...]
Compiling with gcc-3.2 gives an initialization of b as follows:
.data
.align 4
.type b.1,@object
.size b.1,4
b.1:
.long 0
-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux astrid 2.4.20-3-686 #1 Sat Jun 7 22:34:55 EST 2003 i686
Locale: LANG=C, LC_CTYPE=sv_SE
Versions of packages gcc-3.3 depends on:
ii binutils 2.14.90.0.7-3 The GNU assembler, linker and bina
ii cpp-3.3 1:3.3.3-0pre2 The GNU C preprocessor
ii gcc-3.3-base 1:3.3.3-0pre2 The GNU Compiler Collection (base
ii libc6 2.3.2.ds1-10 GNU C Library: Shared libraries an
ii libgcc1 1:3.3.3-0pre2 GCC support library
-- no debconf information
Reply to: