This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: 1008 segfaults in genattr
- To: egcs at cygnus dot com
- Subject: Re: 1008 segfaults in genattr
- From: mrs at wrs dot com (Mike Stump)
- Date: Fri, 21 Nov 1997 12:06:38 -0800
> To: Robert Lipe <robertl@dgii.com>
> Cc: egcs@cygnus.com
> From: Jason Merrill <jason@cygnus.com>
> Date: 20 Nov 1997 22:03:51 -0800
> >>>>> Robert Lipe <robertl@dgii.com> writes:
> > 4) Make the test case call _exit() instead of exit(), but just
> > let code in the field learn this the hard way.
> I think I'm going to go with #4.
I'd prefer either a fixed atexit, or if we can stick in code to the
testcase to detect infinite looping, if that is the problem, and call
abort (or _exit in that case).
The reason is that the compiler uses atexit internally by itself to
implement C++ semantics, and if it doesn't work well enough, the
semantics it presents to the user will be flawed (in my opinion).
Now, the ANSI C++ may state the users program is flawed, and it is,
they should not be calling exit from global dtors, but under the label
of quality of implementation, we have a chance to do what I think is
the right thing, and it is reasonable to have a testcase for it.
Is it sufficient to change the testcase like the below? If it is,
then that is the solution I prefer, along with a // execution test
fails - XFAIL *-*-sco*, or whatever is needed to mark it.
// prms-id: 9732
int count;
int bail = 0;
struct base {
base () { ++count; }
~base () { --count; }
base(const base&o) { ++count; }
};
class D {
public:
~D() {
if (bail++)
{
// On some Linux boxes, we run the dtor for d twice,
// once before exit, and once after!
abort ();
}
else
{
if (count != 0)
abort ();
exit (0);
}
}
} d;
base base_object;
base base_returning_function ();
const base& base_ref = base_returning_function ();
int main () {
}
base base_returning_function () {
base local_base_object;
return local_base_object;
}