public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/31809] [4.1/4.2/4.3 Regression] sometimes TREE_READONLY is still set for non read only variables causing wrong code Date: Thu, 31 May 2007 10:01:00 -0000 [thread overview] Message-ID: <20070531100058.18989.qmail@sourceware.org> (raw) In-Reply-To: <bug-31809-6528@http.gcc.gnu.org/bugzilla/> ------- Comment #8 from jakub at gcc dot gnu dot org 2007-05-31 10:00 ------- I saw was_readonly as well and wondered if it might be a problem or not, then incorrectly assumed REFERENCE_TYPEs can't be an issue, but as PR31806 shows, they apparently are. 2007-05-31 Jakub Jelinek <jakub@redhat.com> PR c++/31806 * decl.c (cp_finish_decl): Also clear was_readonly if a static var needs runtime initialization. --- gcc/cp/decl.c.jj 2007-05-30 21:03:07.000000000 +0200 +++ gcc/cp/decl.c 2007-05-31 11:32:48.000000000 +0200 @@ -5361,8 +5361,12 @@ cp_finish_decl (tree decl, tree init, bo /* If a TREE_READONLY variable needs initialization at runtime, it is no longer readonly and we need to avoid MEM_READONLY_P being set on RTL created for it. */ - if (init && TREE_READONLY (decl)) - TREE_READONLY (decl) = 0; + if (init) + { + if (TREE_READONLY (decl)) + TREE_READONLY (decl) = 0; + was_readonly = 0; + } expand_static_init (decl, init); } } should cure this. Regarding the performance degradation, to cure this, we'd either have to revert to RTX_UNCHANGING_P (which we know just leads to tremendous amount of bugs), or introduce a way to say "this tree resp. this rtl is readonly in all functions but <this set of fndecls>". For filescope C++ vars that need runtime the set is certainly static initialization and destruction, all functions inlined into it and then depends on how aggresive IPA optimizations want to be, if one day they choose to clone some constructor of a initialized once, then read-only variable and the optimizers would assume that var is readonly, we'd again miscompile things. For function-scope static vars we'd need to put the containing function into the set, so it probably won't help there at all. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31809
next prev parent reply other threads:[~2007-05-31 10:01 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-05-04 0:25 [Bug c++/31809] New: " pinskia at gcc dot gnu dot org 2007-05-04 0:26 ` [Bug c++/31809] " pinskia at gcc dot gnu dot org 2007-05-04 9:33 ` rguenth at gcc dot gnu dot org 2007-05-11 20:02 ` mmitchel at gcc dot gnu dot org 2007-05-25 11:39 ` jakub at gcc dot gnu dot org 2007-05-28 1:12 ` mmitchel at gcc dot gnu dot org 2007-05-30 17:58 ` jakub at gcc dot gnu dot org 2007-05-30 21:24 ` jakub at gcc dot gnu dot org 2007-05-30 22:46 ` mueller at gcc dot gnu dot org 2007-05-30 23:03 ` mark at codesourcery dot com 2007-05-31 9:06 ` mueller at gcc dot gnu dot org 2007-05-31 10:01 ` jakub at gcc dot gnu dot org [this message] 2007-05-31 16:33 ` mark at codesourcery dot com 2007-06-08 21:49 ` [Bug c++/31809] [4.1/4.2 " mueller at gcc dot gnu dot org 2007-06-20 16:27 ` [Bug c++/31809] [4.1 " mueller at gcc dot gnu dot org 2007-06-20 16:28 ` mueller at gcc dot gnu dot org
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=20070531100058.18989.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).