Bug 22575 - immutable object placed in .bss section.
Summary: immutable object placed in .bss section.
Status: RESOLVED DUPLICATE of bug 4131
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.0
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2005-07-20 18:41 UTC by Pawel Sikora
Modified: 2005-11-18 00:55 UTC (History)
5 users (show)

See Also:
Host: i686-pld-linux
Target: i686-pld-linux
Build: i686-pld-linux
Known to work:
Known to fail:
Last reconfirmed: 2005-09-12 15:26:46


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2005-07-20 18:41:04 UTC
class obj { 
private: 
    int value; 
private: 
    obj() { } 
    obj(int v) : value(v) { } 
public: 
    int getValue() const { return value; } 
    const static obj seven; 
}; 
 
const obj obj::seven = obj(7); 
 
int getSeven() 
{ 
    return obj::seven.getValue(); 
} 
 
gcc (3.3.6,4.1.0) places this immutable const static object 
in .bss section and calls constructor(int) in .ctors section. 
why it isn't placed in .rodata ?
Comment 1 Andrew Pinski 2005-07-20 18:44:26 UTC

*** This bug has been marked as a duplicate of 4131 ***
Comment 2 Paul Schlie 2005-07-20 18:57:25 UTC
(In reply to comment #1)
> 
> *** This bug has been marked as a duplicate of 4131 ***

Please correct me if I misunderstand, but it doen't seem reasonable to
close this bug as won't fix, based on it being difficult to fix for v2.95?
Comment 3 Wolfgang Bangerth 2005-07-20 19:47:20 UTC
*** Bug 4131 has been marked as a duplicate of this bug. ***
Comment 4 Wolfgang Bangerth 2005-07-20 19:48:21 UTC
This is a valid bug, however hard it may be to solve (see PR 4131). 
Comment 5 Giovanni Bajo 2005-07-21 02:08:04 UTC
Does ICC put this in .rodata?
Comment 6 Wolfgang Bangerth 2005-07-21 23:00:56 UTC
No, icc puts it into bss and runs code to initialize it with 7: 
 
	.bss 
	.align 4 
	.globl _ZN3obj5sevenE 
_ZN3obj5sevenE: 
	.type	_ZN3obj5sevenE,@object 
	.size	_ZN3obj5sevenE,4 
	.space 4	# pad 
	.data 
	.align 4 
 
W. 
Comment 7 Andrew Pinski 2005-11-18 00:55:22 UTC
This is a dup of bug 4131.

*** This bug has been marked as a duplicate of 4131 ***

*** This bug has been marked as a duplicate of 4131 ***