https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101669
Bug ID: 101669 Summary: error reading variable from debug information when compiling with -O2 Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: guojiufu at gcc dot gnu.org Target Milestone: --- For below case: ----------gdb.f90 integer :: a(10), b(12) call sub (a, 10) call sub (b, 12) write (*,*) a, b end subroutine sub (a, n) integer :: a(n), n integer(kind=8) nl, i nl = n do i = 1, nl a(i) = i end do write (*,*) a end subroutine ------------ At -O2, using command "gfortran -O2 -g ~/temp/gdb.f90 -o arg1.exe" to compile, when debugger it with gdb, there is log: a=<error reading variable: dwarf2_find_location_expression: Corrupted DWARF expression.> $ gdb arg1.exe ... (gdb) b sub Breakpoint 1 at 0x400710: file /home/guojiufu/temp/gdb.f90, line 7. (gdb) r Starting program: /home/guojiufu/gcc/build/gcc-mainline-base/arg1.exe Breakpoint 1, sub (a=<error reading variable: dwarf2_find_location_expression: Corrupted DWARF expression.>, n=10) at /home/guojiufu/temp/gdb.f90:7 7 subroutine sub (a, n) This msg does not occur when compiling with -O3 -g. This issue can be reproduced on x86/ppc64le with the latest trunk, and also occur in gcc11.