0

When I enter "n", the gdb will ignore all the lines below line 35 and jump to previous line.

I have turned off the optimization by adding -O0, but the problem remains.

Breakpoint 1, other_MAIT_create (max_deno=10, MAIT_node=0x7fffffffdad0, nume=9, deno=1024, output_site=0x7fffffffdb10, 
    parent=0x7fffffffdaf0, MAIT_sign=3, save_num=0x7fffffffdab4) at create.cpp:33
33    clean_sign(MAIT_node);
(gdb) n
35    for(unsigned int i=max_deno-1;i>-1;i--)
(gdb) n
8     two_d_node node_split;
(gdb) n
7     node split_single;
(gdb) n
6     infor split_temp;
(gdb) n
93  }
(gdb) n
main (argc=1, argv=0x7fffffffdc98) at main.cpp:32
32    for(unsigned int i=2;i<number;i++)

the max_deno = 10

Lanoz
  • 3
  • 1

1 Answers1

1

This looks like gdb stops before it invokes the destructors of the objects on the stack.

By the way, i>-1 can never be true as long as i is unsigned int. That is, it is wrong to expect that gdb moves forward into the loop body of the for loop whose first line we see in your post.

j6t
  • 9,150
  • 1
  • 15
  • 35
  • Oh, I see. Do you mean that It jumps to 8, 7, 6 lines to invoke destructors because gdb realizes that the loop in line 35 is a dead loop and decide not to enter it? – Lanoz Nov 05 '19 at 12:39
  • May be in i > -1, -1 is seen as an unsigned number which is very big – Lanoz Nov 05 '19 at 12:43
  • Yes, this is in fact the case: not just "very big", but the biggest number that an `unsigned int` can represent. – j6t Nov 05 '19 at 13:07
  • "`i > -1` can never be true" -- did you mean "is always true" ? – Employed Russian Nov 05 '19 at 15:25
  • @EmployedRussian Nope. -1 converted to `unsigned int` is `std::numeric_limits::max()`. There cannot be a larger `unsigned int` value than that. Therefore, the expression is always false. – j6t Nov 05 '19 at 21:14