Closed
Description
There's a minor inconsistency between ECMA III.4.31 (throw) and ECMA III.4.24 (rethrow). The former claims that the stack is emptied after this opcode (which is in alignment with other similar opcodes like leave and endfinally), while the latter makes no mention of clearing the stack. One would expect that if throw clears the stack then rethrow should as well, since they're effectively doing the same thing (minus a pop). The spec for rethrow should be updated to call this out. FWIW, peverify confirms this and successfully verifies what's below:
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
.ver 4:0:0:0
}
.assembly ConsoleApplication24
{
.hash algorithm 0x00008004
.ver 1:0:0:0
}
.module Foo.exe
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003
.corflags 0x00020003
.class private auto ansi beforefieldinit Foo.Program extends [mscorlib]System.Object
{
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
.try
{
leave.s done
}
catch [mscorlib]System.Object
{
dup
dup
dup
dup
dup
dup
dup
rethrow
}
done: ret
}
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed
{
ldarg.0
call instance void [mscorlib]System.Object::.ctor()
ret
}
}