This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/16568] [3.5 regression] wrong code for conditional in initializer


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]