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++/11376] [3.3/3.4 regression] mozilla-1.4 miscompiled


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11376



------- Additional Comments From kevin dot hendricks at sympatico dot ca  2003-07-08 02:05 -------
Subject: Re:  [3.3/3.4 regression] mozilla-1.4 miscompiled

Hi,

> As a hint for further testcase reduction: make all classes structs, and
> remove the public/private/protected markers. Then try to do some of
> the inlining by hand, by replacing the use of accessor functions by
> direct accesses of the respective values, and subsequent removal of
> the accessor functions.

Okay- following along those lines we now get tcase5.cxx

#include <cstdio>
struct A {
  virtual int Setit(int k) = 0;
};

struct B : A {
    int i;
    int Setit(int k) { i = k; }
};

struct SP {
    A * a;
    void ** begin_assign();
};
void ** SP::begin_assign() { return reinterpret_cast< void **> (&a); }

int
main(int argc, char** argv)
{
    SP p;
    B** retval = reinterpret_cast<B**> (p.begin_assign());
    *retval = new B();
    (p.a)->Setit(0);
    fprintf(stderr,"done\n"); fflush(stderr);
    return 0;
}

[kbhend@base1 huh]$ g++ -O2 -o tcase5 tcase5.cxx
[kbhend@base1 huh]$ ./tcase5
Segmentation fault


[kbhend@base1 huh]$ g++ -O2 -fno-strict-aliasing -o tcase5 tcase5.cxx
[kbhend@base1 huh]$ ./tcase5
done

[kbhend@base1 huh]$ g++ -O2 -finline-functions -o tcase5 tcase5.cxx
[kbhend@base1 huh]$ ./tcase5
done

Kevin


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