This is the mail archive of the
mailing list for the GCC project.
Injecting a function into code generation
- From: Sebastian Redl <sebastian dot redl at getdesigned dot at>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 22 May 2008 14:36:22 +0200
- Subject: Injecting a function into code generation
I'm currently trying to implement the C++09 exception propagation
proposal (N2179). See the thread at
in the libstdc++ list for details.
As I say in my first follow-up, I need a copy constructor for any type
with a consistent signature. In other words, I need a function like this:
template <typename T>
void copy_constructor(T *dest, const T *src)
new (dest) T(*src);
Then I can generate the equivalent of
void (*copy)(void*, const void*) = reinterpret_cast<void (*)(void*,
to get a function that can copy-construct an arbitrary type (given that
I know the type, which I do).
The problem is that, since this stuff is done in the tree building in
except.c, I can't rely on any header having been included and defining
such a function.
How can I generate this function in code? I need one instantiation per
type that is thrown, and it would be nice to avoid defining the function
anew for every throw expression. I tried finding an existing case of
this in the source, but I can't think of any place where such a thing
would be done, except perhaps generation of an implicit special member.
But I can't find those.