c++ cli - C++/CLI seems to skip a line of code and debugging does not show the variable declared and defined in that line -
i have been developing in c++/cli , c++ few months seems me programming language should not matter regarding issue.
in following lines of code, double k = (yend - ystart) / (xend - xstart); appears not executed.
//double k = 1.0; if (xend - xstart == 0) { selected = true; return true; } // checks if y-coordinate corresponds x-coordinate else { // calculating slope of line double k = (yend - ystart) / (xend - xstart); if (fabs(y - (ystart + k * (x - xstart))) < (double)selectiontolerance) { selected = true; return true; } } i have tried debug line line f11 , have set breakpoints, though these breakpoints move when running debugger said line if (fabs(y - (ystart + k * (x - xstart))) < (double)selectiontolerance) after it.
i have checked in options of visual studio not skip properties/operations, didn't help. when debugger halts program @ if, can not see value of k, can see other ones without problems (with exception of char selectiontolerance , bool selected, of them double well).
thank help, have searched web , stackoverflow long time not find problem line simple (and general) this.
update:
thanks david yaw , g k, able see value of k. still puzzled issue illustrated here: http://i.imgur.com/myvgtwj.png (cannot yet post images)
even though yend, ystart, xend, xstart of type double , have values seen in image above, when program halts @ line 254 before executing k=ydif/xdif;, k equals 0.0000000000000000. added 3 lines
double ydif= (yend-ystart);
double xdif=xend-xstart;
k=ydif/xdif;
to see if k calculated wanted, got same value after pressing f11 again (program halts @ line 256).
i found question related jumping breakpoint issue here: visual studio breakpoints being moved
what problem calculating k way try it, , correct way it?
you didn't mention calculation incorrect, line of code wasn't getting hit. i'm assuming calculation correct.
the local variable optimized out compiler. since used k in 1 spot, eliminated local variable, , did slope calculation inline, in if statement.
i've seen c++/cli compiler similar things method calls: i've gotten exceptions stack trace lists method don't call: method call inlined, , stack trace pointed method called.
Comments
Post a Comment