COMMAND: g++ ./test_case.cpp -O2 -o test_case.o -g gdb ./test_case (gdb) b main (gdb) r 9 ~Container_1() {} (gdb) p var1767 $1 = 5000 (gdb) stepi 0x000000000040110b 9 ~Container_1() {} (gdb) p var1767 $2 = 10003 lldb ./test_case (lldb) b main (lldb) r 87 return 0; -> 88 } (lldb) p var1767 (long) 10003 (lldb) stepi (lldb) p var1767 (long) 10003 The printing results of lldb and gdb are inconsistent. I think this should be a problem with gdb, because gdb shows that it is in the destructor and the main function is about to end. The value of variable var1767 should have been updated, not the initial value at the beginning. g++ --version: g++ (GCC) 14.2.0 Copyright (C) 2024 Free Software Foundation, Inc. gdb --version GNU gdb (GDB) 13.2 Copyright (C) 2023 Free Software Foundation, Inc. Ubuntu 20.04
Created attachment 15971 [details] test_case.cpp
Dup of PR28987, which is fixed since gdb-15.1. *** This bug has been marked as a duplicate of bug 28987 ***