Functions with multiple entry points

Martin v. Loewis
Sun Feb 20 12:48:00 GMT 2000

> 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.


More information about the Gcc mailing list