public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: k_satoda@f2.dion.ne.jp To: gcc-gnats@gcc.gnu.org Subject: optimization/4131: Why the C++ compiler don't place a const class object to ".rodata" section? Date: Sun, 26 Aug 2001 09:46:00 -0000 [thread overview] Message-ID: <20010826163655.31142.qmail@sourceware.cygnus.com> (raw) >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:
reply other threads:[~2001-08-26 9:46 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20010826163655.31142.qmail@sourceware.cygnus.com \ --to=k_satoda@f2.dion.ne.jp \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).