Question: Can the plain throw statement in C# ever cause a new exception in itself?


Note that I ask this question out of curiosity, not because I have any practical or real-world situation where it would matter much. Also note that my gut feeling and experience tell me that the answer is "No", but I'm looking to validate that answer somehow (see further down on sources I've tried so far).

Here's some sample code to illustrate my question:

try
{
    int x = 0, y = 1 / x;
}
catch (Exception outerException)
{

    try
    {
        throw;
    }
    catch (Exception innerException)
    {
        // Q: Does this Assert ever fail??
        System.Diagnostics.Debug.Assert(outerException.Equals(innerException));
    }
}

I'm wondering if there's any way at all to alter the circumstances such that the Assert will fail, without touching the inner try/catch block.

What I've tried or was looking to try to answer this:

  • Read the throw (C# Reference) page on MSDN - no definitive answer;
  • Checked part 5.3.3.11 of the C# Language Specification - which is probably the wrong place to look for this kind of info;
  • Glossed through the exceptions that I could try to trigger on the throw statement. The OutOfMemoryException comes to mind, but is kind of hard to trigger at the time of the throw.
  • Opened up ILDASM to check the generated code. I can see that throw translates to a rethrow instruction, but I'm lost where to look further to check if that statement can or cannot throw an exception.

This is what ILDASM shows for the inner try bit:

.try
{
  IL_000d:  nop
  IL
Edit
Report