This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16568] [3.5 regression] wrong code for conditional in initializer
- From: "snyder at fnal dot gov" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Jul 2004 17:40:36 -0000
- Subject: [Bug c++/16568] [3.5 regression] wrong code for conditional in initializer
- References: <20040715161157.16568.snyder@fnal.gov>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From snyder at fnal dot gov 2004-07-15 17:40 -------
Subject: Re: [3.5 regression] wrong code for conditional in initializer
> pushl %ebp
> movl %esp, %ebp
> subl $8, %esp
> movl 8(%ebp), %eax
> movl %eax, (%esp)
> call _Z12show_addressPKv
>Whatever used to be in %(esp) isn't used here at all, i.e. both
>the addresses of the argument as well as of *this are unaffected.
Sure it is. After the call and push of bp, it's at bp+8 --- which
is what we read for the call to show_address.
Here's a complete program that shows this.
When i compile and run this, it prints `0', then segfaults.
------------------------------------------------
extern "C" int printf (...);
struct ystr {
ystr (int) {}
ystr (const ystr&) { printf ("%x\n", this); x = 0;}
int x;
};
struct C
{
C(ystr* value);
ystr _object;
};
C::C(ystr* value)
: _object(value == 0 ? 0 : *value)
{
}
int main() {
ystr y (0);
C c (&y);
return 0;
}
------------------------------------------------
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16568