This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Functions with multiple entry points
- To: jbuck at possibly dot synopsys dot com
- Subject: Re: Functions with multiple entry points
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Sun, 20 Feb 2000 21:39:27 +0100
- CC: gcc at gcc dot gnu dot org
- References: <200002201708.JAA11577@possibly.synopsys.com>
> Is that really such a great improvement over
>
> void dtor_with_delete(){
> dtor_without_delete();
> invoke_delete();
> }
>
> void dtor_without_delete(){
> call_base_dtors_without_delete();
> do_local_dtor_stuff();
> }
>
> ?
Perhaps not. I was looking for a simple example, and perhaps took a
too simple one. In the case of the destructor, you also have different
entry points whether you want to tear down the virtual bases or not.
Symmetrically, during construction, you have additional entry points
whether you want to construct the virtual bases or not. You cannot
produce a wrapper constructor in the general case; in particular, it
does not work for varargs functions.
The same holds for functions with covariant returns, consider
struct Base{
virtual Base* foo(int);
};
struct Derived:OtherBase,virtual Base{
Derived *foo(int);
}
Then, Derived::foo must be implemented as
Derived* foo_returning_Derived(int){
do stuff, return value;
}
Base* foo_returning_Base(int value){
return foo_returning_Derived(value)->Base_vbase_pointer;
}
Again, this implementation approach breaks when foo is a varargs
function. Using thunks also breaks, since you need some action *after*
the wrapped function returns; the current thunks only allow actions
before invoking the thunked function.
Regards,
Martin