Bug 6871 - [3.3/3.4 regression] const objects shouldn't be moved to .bss
Bug#: 6871 Product:  gcc Version: unknown
Host:  Target:  Build: 
Status: RESOLVED Severity: normal Priority: P3
Resolution: FIXED Assigned To: jason@gcc.gnu.org Reported By: drepper@redhat.com
Component: rtl-optimization Target Milestone: ---
Summary: [3.3/3.4 regression] const objects shouldn't be moved to .bss
Keywords:  missed-optimization
Opened: 2002-05-30 08:56
Description:   Last confirmed: Opened: 2002-05-30 08:56
The gcc CVS trunk contains code which moves variables which are initialized
with all zeros into .bss (instead of .data).  But the current gcc doesn't stop
there: it also moves constants into .bss instead of .text.  This is not what
should happen since the .bss cannot be shared, unlike the .text.

Release:
gcc CVS trunk 2002-05-29

Environment:
x86 Linux

How-To-Repeat:
Compile the attached file with
  gcc -O2 -c u.c

The variable should be in .text and not in .bss.

------- Comment #1 From Eric Botcazou 2003-02-19 10:10 -------
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed on 3.3 and mainline.

------- Comment #2 From Jason Merrill 2003-03-14 20:42 -------
Responsible-Changed-From-To: unassigned->jason
Responsible-Changed-Why: i'll take a look

------- Comment #3 From Jason Merrill 2003-03-15 01:42 -------
From: jason@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: optimization/6871
Date: 15 Mar 2003 01:42:13 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	jason@gcc.gnu.org	2003-03-15 01:42:13
 
 Added files:
 	gcc/testsuite/gcc.dg: section1.c 
 
 Log message:
 	PR optimization/6871
 	* varasm.c (assemble_variable): Leave constant zeroes in .rodata.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/section1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
 


------- Comment #4 From Jason Merrill 2003-03-15 01:42 -------
From: jason@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: optimization/6871
Date: 15 Mar 2003 01:42:56 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	jason@gcc.gnu.org	2003-03-15 01:42:56
 
 Modified files:
 	gcc            : ChangeLog 
 
 Log message:
 	PR optimization/6871
 	* varasm.c (assemble_variable): Leave constant zeroes in .rodata.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.17086&r2=1.17087
 


------- Comment #5 From Jason Merrill 2003-03-15 01:43 -------
From: jason@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: optimization/6871
Date: 15 Mar 2003 01:43:07 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	jason@gcc.gnu.org	2003-03-15 01:43:07
 
 Modified files:
 	gcc            : varasm.c 
 
 Log message:
 	PR optimization/6871
 	* varasm.c (assemble_variable): Leave constant zeroes in .rodata.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/varasm.c.diff?cvsroot=gcc&r1=1.333&r2=1.334
 


------- Comment #6 From Jason Merrill 2003-03-15 01:44 -------
State-Changed-From-To: analyzed->closed
State-Changed-Why: fixed.

------- Comment #7 From Jason Merrill 2003-03-15 01:44 -------
From: jason@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: optimization/6871
Date: 15 Mar 2003 01:44:40 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	jason@gcc.gnu.org	2003-03-15 01:44:40
 
 Modified files:
 	gcc            : ChangeLog varasm.c 
 
 Log message:
 	PR optimization/6871
 	* varasm.c (assemble_variable): Leave constant zeroes in .rodata.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.299&r2=1.16114.2.300
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/varasm.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.324.2.1&r2=1.324.2.2