public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "trashyankes at wp dot pl" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52067] New: force sibling call optimization Date: Tue, 31 Jan 2012 14:51:00 -0000 [thread overview] Message-ID: <bug-52067-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52067 Bug #: 52067 Summary: force sibling call optimization Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: trashyankes@wp.pl code: ------------------------------- ------------------------------- template<typename T> int loop(int a) __attribute__((optimize(3))); template<typename T> int loop(int a) { T zz; a -= 1; if(a>0) return loop<T>(a); return a; } class pod { }; class not_pod { public: not_pod() {} }; void main() { loop<pod>(10); //use tail call loop<not_pod>(10); //dont use tail call } ------------------------------- ------------------------------- I want use sibling call optimization and build around this my system. But because C++ types can break this optimization without any waring, I could get unexpected stack overflow. It would be good if GCC have attribute that force function to use sibling call and if that is impossible, break compilation with error. something like this: ------------------------------- ------------------------------- int foo(int a) __attribute__((siblingcall)); int foo(int a) { std::string b = "abc"; //Error, have destructor { std::string b2 = "zzz"; //OK, destroyed before any tail call } if(a==1) return foo(a+1); //OK if(a==2) return 1+foo(a+1); //Error, except tail call if(a==3) { int c = foo(a+1); //OK, normal call return c; } return 0; //OK } ------------------------------- -------------------------------
next reply other threads:[~2012-01-31 14:11 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-01-31 14:51 trashyankes at wp dot pl [this message] 2012-01-31 15:06 ` [Bug c++/52067] " rguenth at gcc dot gnu.org 2012-01-31 18:28 ` trashyankes at wp dot pl
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=bug-52067-4@http.gcc.gnu.org/bugzilla/ \ --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).