public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hhinnant at apple dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/25979] New: incorrect codegen for conditional Date: Thu, 26 Jan 2006 17:29:00 -0000 [thread overview] Message-ID: <bug-25979-11686@http.gcc.gnu.org/bugzilla/> (raw) I'm not positive whether or not this is a duplicate of 25895. I figured I'd better enter it just in case it wasn't. Test case: #include <stdio.h> struct A { A() : data1_(0), data2_(0) {} A(int i, int j) : data1_(i), data2_(j) {} A operator+(int); friend A operator+(int, const A&); ~A() {} //private: int data1_; int data2_; }; extern bool x; void display(const A& x) { printf("%d %d\n", x.data1_, x.data2_); } int main() { A a1(1,2); a1 = (x ? a1 + 3 : 3 + a1); display(a1); } bool x = false; A A::operator+(int i) { A a; a = *this; a.data2_ = i; return a; } A operator+(int i, const A& x) { A a; a = x; a.data1_ = i; return a; } Output: 3 0 Expected output: 3 2 The gimple tree (-fdump-tree-gimple) is showing statements like: operator+ (&a1, 3, &a1) [return slot addr]; which shoud instead be: operator+ (temp, 3, &a1) [return slot addr]; ... a1 = temp; The bad codegen is sensitive to the presence or absence of special member functions. For example if you comment out ~A(), you get the expected output. -- Summary: incorrect codegen for conditional Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hhinnant at apple dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25979
next reply other threads:[~2006-01-26 17:29 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2006-01-26 17:29 hhinnant at apple dot com [this message] 2006-01-26 17:31 ` [Bug c++/25979] " pinskia at gcc dot gnu dot org 2006-01-26 17:36 ` pinskia at gcc dot gnu dot org 2006-01-26 17:39 ` pinskia at gcc dot gnu dot org 2006-01-26 17:43 ` [Bug c++/25979] [4.0/4.1/4.2 Regression] incorrect codegen for conditional [SVO issue] pinskia at gcc dot gnu dot org 2006-01-26 18:17 ` pinskia at gcc dot gnu dot org 2006-01-27 20:09 ` jason at gcc dot gnu dot org 2006-02-01 3:08 ` mmitchel at gcc dot gnu dot org 2006-02-03 21:56 ` jason at gcc dot gnu dot org 2006-02-03 21:57 ` jason at gcc dot gnu dot org 2006-02-03 21:59 ` jason at gcc dot gnu dot org 2006-02-04 10:34 ` [Bug c++/25979] [4.0 " steven at gcc dot gnu dot org 2006-02-09 9:54 ` jason at gcc dot gnu dot org 2006-02-10 17:32 ` jason at gcc dot gnu dot org 2006-02-11 0:19 ` jason at gcc dot gnu dot org 2006-02-11 0:51 ` pinskia 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-25979-11686@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).