This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: turning throw into a jump


On Tue, Jul 24, 2001 at 09:48:14AM +0200, Sylvain Pion wrote:
> void f()
> {
>   try
>   {
>     throw int();
>   }
>   catch (int i)
>   {
>   }
> }

Oh, that.  No, we can't do that -- there's more going on behind
the scenes that it looks.

What we do now that we didn't before was handle cleanups and
nested regions with branches.  E.g.

  	try {
	  HasDestructor obj;
	  throw A();
	}
	catch (A &) {
	  foo();
	}

would previously be compiled to something sort of equivalent to

	try {
	  try {
	    HasDestructor obj;
	    throw A();
	  }
	  catch (...) {
	    try {
	      obj->~HasDestructor();
	    }
	    catch (...) {
	      std::terminate();
	    }
	    rethrow;
	  }
	}
	catch (A &) {
	  foo();
	}

whereas now it will be more like

	try {
	  HasDestructor obj;
	  throw A();
	}
	catch {
	  nothrow_region {
	    obj->~HasDestructor();
	  }
	  if (magic_catch_action_number == 1)
	    foo();
	}


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]