Bugzilla – Bug 316260
codeflow problem with if+goto
Last modified: 2007-09-15 21:24:34 UTC
---- Reported by toshok@ximian.com 2004-10-18 15:06:21 MST ---- static void TestGoto (bool hi) { if (hi) goto boo; Console.WriteLine ("didn't goto"); boo: Console.WriteLine ("here I am"); } if the debugger is stopped on the "if (hi)" line, and hi == true, "next" takes us directly to the Console.WriteLine ("here I am") instead of taking us to the "goto boo" line. ---- Additional Comments From martin@ximian.com 2004-10-20 01:01:54 MST ---- Ok, I don't think this is a bug - at least it's nothing we can fix on i386. Here's the assembler code: ===== X.TestGoto(System.Boolean): 0x40986be0 push %ebp 0x40986be1 mov %esp,%ebp 0x40986be3 push %edi 0x40986be4 push %esi 0x40986be5 call 0x400e31f0:mono_domain_get 0x40986bea mov %eax,%esi 0x40986bec movzbl 0x8(%ebp),%eax 0x40986bf0 test %eax,%eax 0x40986bf2 jne 0x40986c0f:X.TestGoto(System.Boolean)+0x2f 0x40986bf4 push $0x1 0x40986bf6 push $0x8153158 0x40986bfb push %esi 0x40986bfc call 0x40986248:__icall_wrapper_mono_ldstr 0x40986c01 add $0xc,%esp 0x40986c04 mov %eax,%edi 0x40986c06 push %edi 0x40986c07 call System.Console.WriteLine(System.String) 0x40986c0c add $0x4,%esp 0x40986c0f push $0x19 0x40986c11 push $0x8153158 0x40986c16 push %esi 0x40986c17 call 0x40986248:__icall_wrapper_mono_ldstr 0x40986c1c add $0xc,%esp 0x40986c1f mov %eax,%esi 0x40986c21 push %esi 0x40986c22 call System.Console.WriteLine(System.String) 0x40986c27 add $0x4,%esp 0x40986c2a lea 0xfffffff8(%ebp),%esp 0x40986c2d pop %esi 0x40986c2e pop %edi 0x40986c2f leave 0x40986c30 ret ===== The important part is this: ===== 0x40986bec movzbl 0x8(%ebp),%eax 0x40986bf0 test %eax,%eax 0x40986bf2 jne 0x40986c0f:X.TestGoto(System.Boolean)+0x2f ===== As you can see, there is no additional `jmp' instruction - the JIT optimized that away. The test case works without problem if you disable all JIT optimizations. ---- Additional Comments From martin@ximian.com 2004-10-20 01:02:38 MST ---- So I think we can close this bug. Unknown operating system unknown. Setting to default OS "Other".