Bug#148651: gcc 3.1-2 patch breaks binutils builds
Jack Howarth <howarth@bromo.msbb.uc.edu> writes:
> HJ Lu has requested that we regress out the g++-cxa-atexit.dpatch
> patch.
The patch, in itself, is correct. Applications that want to conform to
the C++ ABI *must* use __cxa_atexit. It is not the default in g++
since not all C libraries support __cxa_atexit. However, GNU libc does
support this function, so Debian (and all other distributions) need to
activate it.
The cxa_atexit machinery was designed to support a number of other
scenarios, too, which are not available with -fno-use-cxa-atexit. As
an example, consider the example below. The correct output of this
example is
Created first
Called second
Created third
Destroyed first
Destroyed second
Destroyed third
The rule here is that destructors should be called in reverse order of
constructors completing, interleaved with calls to atexit functions.
Other similar examples involve globals that call functions with
block-local static variables.
The patch must stay, and the system must support it properly.
Regards,
Martin
#include <stdio.h>
#include <stdlib.h>
struct Order{
char *fini;
Order(char*, char*, bool);
~Order();
};
void c_fini(){
printf("Destroyed second\n");
}
void c_init(){
printf("Called second\n");
atexit(c_fini);
}
Order::Order(char* init, char* fini, bool atexit):fini(fini)
{
if(atexit)
c_init();
printf("Created %s\n", init);
}
Order::~Order()
{
printf("Destroyed %s\n", fini);
}
Order o1("first", "third", false);
Order o2("third", "first", true);
int main(){}
--
To UNSUBSCRIBE, email to debian-gcc-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: