This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix -fzero-initialized-in-bss bug
- From: Richard Henderson <rth at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 3 Mar 2002 01:01:17 -0800
- Subject: fix -fzero-initialized-in-bss bug
Shows up building glibc. The problem is that we emitted a
common symbol instead of a bss symbol. We did that because
the variable was incorrectly marked common.
r~
* c-decl.c (start_decl): Initialized variables are not common.
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.303
diff -u -p -r1.303 c-decl.c
--- c-decl.c 2002/02/28 13:29:47 1.303
+++ c-decl.c 2002/03/03 08:54:38
@@ -3476,7 +3476,7 @@ start_decl (declarator, declspecs, initi
initializer equal to zero. (Section 3.7.2)
-fno-common gives strict ANSI behavior. Usually you don't want it.
This matters only for variables with external linkage. */
- if (! flag_no_common || ! TREE_PUBLIC (decl))
+ if (!initialized && (! flag_no_common || ! TREE_PUBLIC (decl)))
DECL_COMMON (decl) = 1;
/* Set attributes here so if duplicate decl, will have proper attributes. */
Index: testsuite/gcc.c-torture/compile/20020303-1.c
===================================================================
RCS file: 20020303-1.c
diff -N 20020303-1.c
--- /dev/null Tue May 5 13:32:27 1998
+++ 20020303-1.c Sun Mar 3 00:56:43 2002
@@ -0,0 +1,5 @@
+/* With -fzero-initialized-in-bss, we made I a common symbol instead
+ of a symbol in the .bss section. Not only does that break semantics,
+ but a common symbol can't be weak. */
+
+int i __attribute__((weak)) = 0;