public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "marco at technoboredom dot net" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/45115] New: attribute((pure)) does not work when returning structs Date: Wed, 28 Jul 2010 19:45:00 -0000 [thread overview] Message-ID: <bug-45115-3116@http.gcc.gnu.org/bugzilla/> (raw) compiling this with 'gcc -O3 -S x.c' -------- x.c ----------- #define PURE __attribute__((pure)) struct res {int u; }; extern struct res calc_1() PURE; extern int calc_2() PURE; int fun_1() { return calc_1().u+calc_1().u; } int fun_2() { return calc_2()+calc_2(); } -------------------- yields code which calls calc_2() *once* in fun_2() but calls calc_1() *twice* in fun_1(). Obviously, fun_1 misses an optimization. Tested on gcc 4.4.3 (Ubuntu 10.04), gcc 4.5.0/4.4.4/4.3.5 (MacPorts) -- Summary: attribute((pure)) does not work when returning structs Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: marco at technoboredom dot net GCC host triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45115
next reply other threads:[~2010-07-28 19:45 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-07-28 19:45 marco at technoboredom dot net [this message] 2010-07-28 19:48 ` [Bug tree-optimization/45115] pure functions returning structs are not optimized pinskia at gcc dot gnu dot org 2010-07-28 20:05 ` rguenth 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=bug-45115-3116@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).