Bug 39791 - [4.3 Regression] Bad Dwarf debug information from gfortran for a character string.
Summary: [4.3 Regression] Bad Dwarf debug information from gfortran for a character st...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.3
: P4 normal
Target Milestone: 4.3.4
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-debug
Depends on:
Blocks:
 
Reported: 2009-04-17 01:45 UTC by David Sagan
Modified: 2009-05-11 09:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.1 4.4.0
Known to fail: 4.3.3
Last reconfirmed: 2009-04-22 13:35:09


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Sagan 2009-04-17 01:45:08 UTC
A simple example shows the problem:

program test
  implicit none
  integer i
  character(16) abc
  abc = "abc"
  i = 7
end program

Compile with:
  gfortran -g -O0 test.f90

Run with gdb and "whatis abc" produces:
  type = character(kind=1) (16)

That is, gdb thinks that the variable abc is an array of length 16 with each component in the array being a singe character. I verified with the totalview debugger that the problem was with the compiler and not gdb. Interestingly enough, version 4.1.1 does *not* have this problem. This bug definitely makes debugging a program more painful.
Comment 1 Tobias Burnus 2009-04-17 04:40:15 UTC
I think this was recently fixed. At least with GCC 4.4.0 20090414 and with the latest 4.5 trunk:

(gdb) pt abc
type = character*16
(gdb) p abc
$1 = 'abc', ' ' <repeats 13 times>

I can reproduce the problem with gfortran 4.3.x
Comment 2 Richard Biener 2009-04-22 13:35:09 UTC
Fortran, P4.  Confirmed as of comment #1.
Comment 3 Tobias Burnus 2009-04-24 07:19:36 UTC
Subject: Bug 39791

Author: burnus
Date: Fri Apr 24 07:19:12 2009
New Revision: 146672

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146672
Log:
2009-04-24  Tobias Burnus  <burnus@net-b.de>

        PR fortran/39791
        Backport from mainline:

        2008-08-22  Jakub Jelinek  <jakub@redhat.com>

        * dwarf2out.c (add_subscript_info): Stop on Fortran
        * TYPE_STRING_FLAG
        types.
        (gen_array_type_die): Emit DW_TAG_string_type for Fortran
        character types.


Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/dwarf2out.c

Comment 4 Tobias Burnus 2009-04-24 07:25:33 UTC
FIXED for 4.3.4. The original patch for the 4.4 trunk was
http://gcc.gnu.org/ml/gcc-patches/2008-08/msg01700.html
Comment 5 Tobias Burnus 2009-05-11 09:17:31 UTC
The patch caused a regression, see PR 40061