http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54382

             Bug #: 54382
           Summary: gfortran show_locus: Invalid read of size 4
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: bur...@gcc.gnu.org


For the following program, valgrind shows:

Invalid read of size 4
at 0x57BD98: _ZL10show_locusP5locusii.isra.3 (error.c:392)
by 0x57C3D5: error_print(char const*, char const*, __va_list_tag*)
(error.c:661)
by 0x57CEF8: gfc_error(char const*, ...) (error.c:956)
by 0x5C3296: match_complex_part(gfc_expr**) (primary.c:1205)


The program consists of the two lines:
!--------------------------
r =                                                                            
              (r + m)
end
!--------------------------

Namely, the first line has 101 characters. It is crucial for this valgrind
warning that the line is very long.

The warning is printed for
   292  show_locus (locus *loc, int c1, int c2)
...
   309    lb = loc->lb;
...
   388    p = &(lb->line[offset]);
   389    for (i = 0; i <= cmax; i++)
   390      {
   391        int spaces, j;
   392        spaces = gfc_widechar_display_length (*p++);

where offset == 21 and, initially, c1 == 96 and c2 == -1.

Reply via email to