public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/4131: Why the C++ compiler don't place a const class object to ".rodata" section?
@ 2001-08-26 9:46 k_satoda
0 siblings, 0 replies; only message in thread
From: k_satoda @ 2001-08-26 9:46 UTC (permalink / raw)
To: gcc-gnats
>Number: 4131
>Category: optimization
>Synopsis: Why the C++ compiler don't place a const class object to ".rodata" section?
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Aug 26 09:46:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Zutoshi
>Release: unknown-2.9
>Organization:
>Environment:
various
>Description:
I want to use a 'fixed-pointed-value' as a replacement of 'floating-point-value'.
But the const instance of my class never be placed to ".rodata" section.
They seem to need ".ctors" , however the constructing code has only a constant instructions to store a certain value.
I think it dosen't need any codes , and needs only few bytes of ".rodata" section.
I tried same test on some compilers , but no one generate the codes I want.
These can be a headache on machines that have little RAM.
Please excuse my poor english typing.(I am a Japanese.)
>How-To-Repeat:
// compile the following with maximam optimization.
class T
{
int raw;
public:
enum { BASE = (1<< 8) };
template<class value_type> T(value_type opr) : raw(static_cast<int>(opr * BASE)) {}
template<class value_type> operator value_type() const { return static_cast<value_type>(raw) / BASE; }
};
const T t1 = 1.0;
const int i1 = static_cast<int>(1.0 * T::BASE);
int main(void)
{
return i1 ^ static_cast<int>(t1);
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-08-26 9:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-26 9:46 optimization/4131: Why the C++ compiler don't place a const class object to ".rodata" section? k_satoda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).