[PATCH] Fix PR optimization/6086

Jakub Jelinek jakub@redhat.com
Tue Apr 2 13:59:00 GMT 2002


On Tue, Apr 02, 2002 at 11:50:21PM +0200, Franz Sirl wrote:
> Daniel Jacobowitz changed the testcase into an executable one and I verified 
> that it fails without your patch and passes with your patch on 
> powerpc-linux-gnu.

Thanks.

> #include <stdlib.h>

Replace this line with:
// PR optimization/6086
// { dg-do run }
// { dg-options "-O" }

extern "C" void abort (void);

(not including any headers is IMHO preferable so that it can be debugged
more easily).

Someone with global write priviledges will have to approve it though.
Dunno how it should be called, maybe g++.dg/opt/preinc1.C?

> struct A
> {
>   A (int x, int y);
>   int a, b;
>   int foo () { return a; }
>   int bar () { return b; }
> };
> 
> struct B
> {
>   virtual ~B ();
>   virtual A baz () const;
> };
> 
> struct C
> {
>   A foo () const;
>   B *c;
> };
> 
> A C::foo () const
> {
>   int x, y;
>   x = c->baz ().foo ();
>   y = c->baz ().bar ();
>   return A (x, y);
> }
> 
> A B::baz () const
> {
>   return A (4, 8);
> }
> 
> A::A (int x, int y)
> {
>   a = x;
>   b = y;
> }
> 
> B::~B ()
> {
> }
> 
> int
> main ()
> {
>   C the_c;
>   B the_b;
>   the_c.c = &the_b;
>   if (the_c.foo().a != 4)
>     abort ();
>   return 0;
> }

	Jakub



More information about the Gcc-patches mailing list