Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm debugging an application in Visual Studio 2010 going step by step and at one point it jumps to an unexpected part of the code. Is this a bug? [closed]

I'm debugging an application in Visual Studio 2010 going step by step and, astonishingly, it jumps back to a part of code that doesn't suppose to, in a non linear manner. I run the code in a unit test, with debug (using resharper) and Visual Studio just stops, it doesn't say stackoverflow or anything after waiting for a while.

I think it is a bug. I happened at another time as well. Why would it jump code in such an arbitrary manner?

Do you know how to prevent this? Is some particular way of coding that makes this bug prone to happen?

Edit: Part of the code where it jumps to:

foreach (var elemento in expresion.ElementosUsados)
        {
            valoresElementos.Add(new ValorYNombre(elemento.Nombre, elemento.GetValor(valoresBase)));
        }

at that time the value of "elemento" would be equal to "this" (a reference to the same object)

like image 821
Fernando Tiberti Avatar asked Dec 04 '22 18:12

Fernando Tiberti


1 Answers

Are you compiling with Optimization enabled? This can lead to code which will not perfectly mimic the flow of your written code but will mimic its functionality. This results in the debugger seemingly jumping from operation to operation.


EDIT by Olivier Jacot-Descombes:

enter image description here

I added the image here, since I cannot add it to a comment.

like image 116
RussS Avatar answered Dec 08 '22 01:12

RussS