Help understanding the CIL of a disassembled C# program. DUP right before a POP?

I've disassembled a .NET binary using IDA Pro and am finding a lot of instances where a dup instruction is immediately followed by a pop. The disassembly is littered with instances of this:

call int32 [blahblahblah] dup pop 

Now as far as I can tell, the dup and pop instructions are redundant… dup is pushing a copy of whatever's on top of the stack onto the stack, and then pop is popping it right back off, no?

I'm curious to see if this is some kind of weird IDA thing, or a strange compilation artifact?

Or (more likely) am I missing something? Is there something weird going on with the stack here?

by Appathy via /r/csharp

Leave a Reply