Bug 29067 - gfc_resolve_expr(): Bad expression type
Summary: gfc_resolve_expr(): Bad expression type
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: 4.1.2
Assignee: Francois-Xavier Coudert
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2006-09-13 20:10 UTC by MC
Modified: 2006-11-03 14:28 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.0
Known to fail: 4.2.0 4.1.2
Last reconfirmed: 2006-10-30 16:46:22


Attachments
source code (893 bytes, text/x-fortran)
2006-09-13 20:18 UTC, MC
Details
work around (2.80 KB, text/x-fortran)
2006-09-14 09:05 UTC, MC
Details

Note You need to log in before you can comment on or make changes to this bug.
Description MC 2006-09-13 20:10:29 UTC
gfortran fails on the attached subroutine.

> gfortran -v -save-temps -c ircmva.f
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20060901 (prerelease) (Debian 4.1.1-13)
 /usr/lib/gcc/i486-linux-gnu/4.1.2/f951 ircmva.f -ffixed-form -quiet -dumpbase ircmva.f -mtune=i686 -auxbase ircmva -version -o ircmva.s
GNU F95 version 4.1.2 20060901 (prerelease) (Debian 4.1.1-13) (i486-linux-gnu)
        compiled by GNU C version 4.1.2 20060901 (prerelease) (Debian 4.1.1-13).
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129579
 In file ircmva.f:91

      END
                                                                       1
 Internal Error at (1):
 gfc_resolve_expr(): Bad expression type



Source code :

      SUBROUTINE IRCMVA ( NUMCMP, NCMPVE, NCMPRF,
     >                    NVALEC, NBPG, NBSP, NOLOPG,
     >                    ADSV, ADSD, ADSL,
     >                    TYMAST, MODNUM, NUANOM,
     >                    VAL, PROFAS, IDEB, IFIN )
      IMPLICIT NONE
      INTEGER NTYMAX
      PARAMETER (NTYMAX = 48)
      INTEGER NCMPVE, NCMPRF, NVALEC, NBPG, NBSP
      INTEGER NUMCMP(NCMPRF)
      INTEGER ADSV, ADSD, ADSL
      INTEGER TYMAST
      INTEGER MODNUM(NTYMAX), NUANOM(NTYMAX,*)
      INTEGER PROFAS(*)
      INTEGER IDEB, IFIN
      REAL*8 VAL(NCMPVE,NBSP,NBPG,NVALEC)
      CHARACTER*32 NOLOPG
      REAL*8       ZR
      LOGICAL      ZL
      COMMON /RVARJE/ZR(1)
      COMMON /LVARJE/ZL(1)
      CHARACTER*6 NOMPRO
      PARAMETER ( NOMPRO = 'IRCMVA' )
      CHARACTER*32 EDELGA
      PARAMETER ( EDELGA='________ELNO____________________' )
      INTEGER IAUX, JAUX, KAUX
      INTEGER ADSVXX
      INTEGER INO, IMA, NRCMP, NRCMPR, NRPG, NRSP
      INTEGER IFM, NIVINF
      LOGICAL LOGAUX
      CALL INFNIV ( IFM, NIVINF )
      IF ( NIVINF.GT.1 ) THEN
        CALL UTMESS ( 'I', NOMPRO,
     > 'CREATION DES TABLEAUX DE VALEURS A ECRIRE AVEC :')
        WRITE (IFM,13001) NVALEC, NCMPVE, NBPG, NBSP
      ENDIF
13001 FORMAT('  NVALEC =',I8,', NCMPVE =',I8,
     >       ', NBPG   =',I8,', NBSP   =',I8,/)
      IF ( TYMAST.EQ.0 ) THEN
        DO 21 , NRCMP = 1 , NCMPVE
          ADSVXX = ADSV-1+NUMCMP(NRCMP)-NCMPRF
          JAUX = 0
          DO 211 , IAUX = IDEB, IFIN
            INO = PROFAS(IAUX)
            JAUX = JAUX + 1
            KAUX = INO*NCMPRF
            VAL(NRCMP,1,1,JAUX) = ZR(ADSVXX+KAUX)
  211     CONTINUE
   21   CONTINUE
      ELSE
        LOGAUX = .FALSE.
        IF ( NOLOPG(9:16).EQ.EDELGA(9:16) ) THEN
          IF ( MODNUM(TYMAST).EQ.1 ) THEN
            LOGAUX = .TRUE.
          ENDIF
        ENDIF
        IF ( LOGAUX ) THEN
          IF ( NBSP.GT.1 ) THEN
            WRITE (IFM,13001) NVALEC, NCMPVE, NBPG, NBSP
            CALL UTMESS ( 'F', NOMPRO,
     >     'RENUMEROTATION IMPOSSIBLE AVEC PLUS D''UN SOUS-POINT')
          ENDIF
        ENDIF
        DO 22 , NRCMP = 1 , NCMPVE
          NRCMPR = NUMCMP(NRCMP)
          JAUX = 0
          IF ( LOGAUX ) THEN
            NRSP = 1
            DO 221 , IAUX = IDEB, IFIN
              IMA = PROFAS(IAUX)
              JAUX = JAUX + 1
              DO 2211 , NRPG = 1 , NBPG
                CALL CESEXI ('C',ADSD,ADSL,IMA,NRPG,NRSP,NRCMPR,KAUX)
                VAL(NRCMP,NRSP,NUANOM(TYMAST,NRPG),JAUX)=ZR(ADSV-1+KAUX)
 2211         CONTINUE
  221       CONTINUE
          ELSE
            DO 222 , IAUX = IDEB, IFIN
              IMA = PROFAS(IAUX)
              JAUX = JAUX + 1
              DO 2221 , NRPG = 1 , NBPG
                DO 2222 , NRSP = 1 , NBSP
                  CALL CESEXI ('C',ADSD,ADSL,IMA,NRPG,NRSP,NRCMPR,KAUX)
                  VAL(NRCMP,NRSP,NRPG,JAUX) = ZR(ADSV-1+KAUX)
 2222           CONTINUE
 2221         CONTINUE
  222       CONTINUE
          ENDIF
   22   CONTINUE
      ENDIF
      END
Comment 1 kargl 2006-09-13 20:17:09 UTC
This compiles with gfortran 4.2, so you may want to update to a
newer compiler.

Does this file contain any TAB characters?
Comment 2 MC 2006-09-13 20:18:41 UTC
Created attachment 12252 [details]
source code

add source file
Comment 3 kargl 2006-09-13 21:42:22 UTC
This compiles with both 

troutmask:sgk[265] gfc41 --version
GNU Fortran 95 (GCC) 4.1.2 20060913 (prerelease)
Copyright (C) 2006 Free Software Foundation, Inc.

troutmask:sgk[266] gfc4x --version
GNU Fortran 95 (GCC) 4.2.0 20060911 (experimental)
Copyright (C) 2006 Free Software Foundation, Inc.

Can you upgrade and confirm that the code compiles?
Comment 4 MC 2006-09-14 09:05:05 UTC
Created attachment 12266 [details]
work around

With some "*1" added, compilation pass !?
Comment 5 MC 2006-09-14 09:08:12 UTC
I try as soon as possible.
Thanks for your help.

This subroutine is one of an open-source project which contains about 1.000.000 lines of fortran : http://www.code-aster.org.

Comment 6 Paul Thomas 2006-10-12 12:18:29 UTC
(In reply to comment #5)
> I try as soon as possible.
> Thanks for your help.
> This subroutine is one of an open-source project which contains about 1.000.000
> lines of fortran : http://www.code-aster.org.

Mathieu,

Can I close this one, please?

Paul Thomas 
Comment 7 Steve Kargl 2006-10-12 14:13:07 UTC
Subject: Re:  Internal Error: gfc_resolve_expr(): Bad expression type

On Thu, Oct 12, 2006 at 12:18:30PM -0000, pault at gcc dot gnu dot org wrote:
> 
> 
> ------- Comment #6 from pault at gcc dot gnu dot org  2006-10-12 12:18 -------
> (In reply to comment #5)
> > I try as soon as possible.
> > Thanks for your help.
> > This subroutine is one of an open-source project which contains about 1.000.000
> > lines of fortran : http://www.code-aster.org.
> 
> Mathieu,
> 
> Can I close this one, please?
> 

I think the anwser to this is "yes".

Comment 8 Francois-Xavier Coudert 2006-10-13 07:38:55 UTC
(In reply to comment #3)
> Can you upgrade and confirm that the code compiles?

No, Steve, it doesn't work for me either on i686-linux. I downloaded the code from comment #2 (and to answer Paul: it doesn't contain any tab), and it fails to compile with

$ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /home/fxcoudert/gfortran_nightbuild/trunk/configure --prefix=/home/fxcoudert/gfortran_nightbuild/irun-20061012 --enable-languages=c,fortran --with-gmp=/home/fxcoudert/gfortran_nightbuild/software
Thread model: posix
gcc version 4.2.0 20061012 (experimental)
$ gfortran -c ircmva.f 
 In file ircmva.f:91

      END                                                               
                                                                       1
 Internal Error at (1):
 gfc_resolve_expr(): Bad expression type

while the same file compiles fine on x86_64-unknown-linux-gnu. The backtrace of the ICE is:

Breakpoint 2, gfc_internal_error (
    format=0x85d2f48 "gfc_resolve_expr(): Bad expression type")
    at /home/fxcoudert/gfortran_nightbuild/trunk/gcc/fortran/error.c:667
667     /home/fxcoudert/gfortran_nightbuild/trunk/gcc/fortran/error.c: No such file or directory.
        in /home/fxcoudert/gfortran_nightbuild/trunk/gcc/fortran/error.c
(gdb) where
#0  gfc_internal_error (
    format=0x85d2f48 "gfc_resolve_expr(): Bad expression type")
    at /home/fxcoudert/gfortran_nightbuild/trunk/gcc/fortran/error.c:667
#1  0x0808e082 in gfc_resolve_expr (e=0x9407790)
    at /home/fxcoudert/gfortran_nightbuild/trunk/gcc/fortran/resolve.c:3107
#2  0x0809162b in resolve_code (code=0x9407588, ns=0x94013a8)
    at /home/fxcoudert/gfortran_nightbuild/trunk/gcc/fortran/resolve.c:4864
#3  0x08093edd in gfc_resolve_blocks (b=0x9407548, ns=0x94013a8)
    at /home/fxcoudert/gfortran_nightbuild/trunk/gcc/fortran/resolve.c:4796
#4  0x080915fa in resolve_code (code=0x9407678, ns=0x94013a8)
    at /home/fxcoudert/gfortran_nightbuild/trunk/gcc/fortran/resolve.c:4853
#5  0x08093edd in gfc_resolve_blocks (b=0x94062f8, ns=0x94013a8)
    at /home/fxcoudert/gfortran_nightbuild/trunk/gcc/fortran/resolve.c:4796
#6  0x080915fa in resolve_code (code=0x9404c68, ns=0x94013a8)
    at /home/fxcoudert/gfortran_nightbuild/trunk/gcc/fortran/resolve.c:4853
#7  0x08092e83 in gfc_resolve (ns=0x94013a8)
    at /home/fxcoudert/gfortran_nightbuild/trunk/gcc/fortran/resolve.c:6919
#8  0x08087d39 in gfc_parse_file ()
    at /home/fxcoudert/gfortran_nightbuild/trunk/gcc/fortran/parse.c:3212
#9  0x080a928d in gfc_be_parse_file (set_yydebug=0)
    at /home/fxcoudert/gfortran_nightbuild/trunk/gcc/fortran/f95-lang.c:303
#10 0x083a6dc5 in toplev_main (argc=14, argv=0xbfc6ba64)
    at /home/fxcoudert/gfortran_nightbuild/trunk/gcc/toplev.c:1033
#11 0x080de53f in main (argc=2, argv=0x0)
    at /home/fxcoudert/gfortran_nightbuild/trunk/gcc/main.c:35

gfc_internal_error is called in resolve.c because, in gfc_resolve_expr, argument e has value:

(gdb) p *e
$2 = {expr_type = 0, ts = {type = BT_INTEGER, kind = 4, derived = 0x0, 
    cl = 0x0}, rank = 0, shape = 0x0, symtree = 0x96ae868, ref = 0x96d77e8, 
  where = {nextc = 0x96cc62b "NUMCMP(NRCMP)", ' ' <repeats 40 times>, 
    lb = 0x96cc608}, from_H = 0, inline_noncopying_intrinsic = 0, value = {
    logical = 0, integer = {{_mp_alloc = 0, _mp_size = 0, _mp_d = 0x0}}, 
    real = {{_mpfr_prec = 0, _mpfr_sign = 0, _mpfr_exp = 0, _mpfr_d = 0x0}}, 
    complex = {r = {{_mpfr_prec = 0, _mpfr_sign = 0, _mpfr_exp = 0, 
          _mpfr_d = 0x0}}, i = {{_mpfr_prec = 0, _mpfr_sign = 0, 
          _mpfr_exp = 0, _mpfr_d = 0x0}}}, op = {
      operator = GFC_INTRINSIC_BEGIN, uop = 0x0, op1 = 0x0, op2 = 0x0}, 
    function = {actual = 0x0, name = 0x0, isym = 0x0, esym = 0x0}, 
    character = {length = 0, string = 0x0}, constructor = 0x0}}

It has expr_type = 0, which should not happen. This happens for symbol numcmp:

(gdb) p *e->symtree
$3 = {priority = 15818, left = 0x0, right = 0x0, name = 0x96d07cd "numcmp", 
  ambiguous = 0, n = {sym = 0x96d20b8, uop = 0x96d20b8, common = 0x96d20b8}}
(gdb) p *e->symtree->n.sym
$4 = {name = 0x96d07cd "numcmp", module = 0x0, declared_at = {
    nextc = 0x96b1f20 ", NCMPVE, NCMPRF,", ' ' <repeats 23 times>, 
    lb = 0x96b1ef0}, ts = {type = BT_INTEGER, kind = 4, derived = 0x0, 
    cl = 0x0}, attr = {allocatable = 0, dimension = 1, external = 0, 
    intrinsic = 0, optional = 0, pointer = 0, save = 0, target = 0, dummy = 1, 
    result = 0, assign = 0, threadprivate = 0, data = 0, use_assoc = 0, 
    in_namelist = 0, in_common = 0, in_equivalence = 0, function = 0, 
    subroutine = 0, generic = 0, implicit_type = 0, untyped = 0, sequence = 0, 
    elemental = 0, pure = 0, recursive = 0, unmaskable = 0, masked = 0, 
    contained = 0, noreturn = 0, entry = 0, entry_master = 0, 
    mixed_entry_master = 0, always_explicit = 0, referenced = 1, 
    is_main_program = 0, access = ACCESS_UNKNOWN, intent = INTENT_UNKNOWN, 
    flavor = FL_VARIABLE, if_source = IFSRC_UNKNOWN, proc = PROC_UNKNOWN, 
    cray_pointer = 0, cray_pointee = 0, alloc_comp = 0}, generic = 0x0, 
  component_access = ACCESS_UNKNOWN, formal = 0x0, formal_ns = 0x0, 
  value = 0x0, as = 0x96d2850, result = 0x0, components = 0x0, 
  cp_pointer = 0x0, common_next = 0x0, common_head = 0x0, dummy_order = 8, 
  entry_id = 0, namelist = 0x0, namelist_tail = 0x0, old_symbol = 0x0, 
  tlink = 0x0, mark = 1, new = 0, equiv_built = 0, forall_index = 0, refs = 1, 
  ns = 0x96d13a8, backend_decl = 0x0}
Comment 9 Francois-Xavier Coudert 2006-10-13 07:54:34 UTC
I managed to trim it down to:

      implicit none
      integer :: n, i
      character(len=16),parameter :: s = ""

      if (s(9:16) == "90123456") then
      endif
      if (i > 0) then
        write (i,*) n
        call foo(0)
      endif
      do i = 1, n
      end do
      end
Comment 10 kargl 2006-10-15 01:20:59 UTC
(In reply to comment #9)
> I managed to trim it down to:
> 
>       implicit none
>       integer :: n, i
>       character(len=16),parameter :: s = ""
> 
>       if (s(9:16) == "90123456") then
>       endif
>       if (i > 0) then
>         write (i,*) n
>         call foo(0)
>       endif
>       do i = 1, n
>       end do
>       end
> 

This trimmed down example is invalid code.  The "if (i>0)"
statement tries to use before it is defined.
Comment 11 kargl 2006-10-15 01:53:10 UTC
I can't reproduce this, so drop assign status.
Comment 12 Francois-Xavier Coudert 2006-10-15 08:40:29 UTC
(In reply to comment #10)
> This trimmed down example is invalid code.  The "if (i>0)"
> statement tries to use before it is defined.

Sorry about that: the following code is valid, and also fails to compile with the same error.

      implicit none
      integer :: n, i
      character(len=16),parameter :: s = ""

      i = 0 ; n = 9
      if (s(9:16) == "90123456") then
      endif
      if (i > 0) then
        write (i,*) n
        call foo(0)
      endif
      do i = 1, n
      end do
      end
Comment 13 Steve Kargl 2006-10-15 16:42:18 UTC
Subject: Re:  Internal Error: gfc_resolve_expr(): Bad expression type

On Sun, Oct 15, 2006 at 08:40:30AM -0000, fxcoudert at gcc dot gnu dot org wrote:
> > This trimmed down example is invalid code.  The "if (i>0)"
> > statement tries to use before it is defined.

s/use before/use 'i' before/

> Sorry about that: the following code is valid, and also fails to compile with
> the same error.
> 
>       implicit none
>       integer :: n, i
>       character(len=16),parameter :: s = ""
> 
>       i = 0 ; n = 9
>       if (s(9:16) == "90123456") then
>       endif
>       if (i > 0) then
>         write (i,*) n
>         call foo(0)
>       endif
>       do i = 1, n
>       end do
>       end
> 

This compiles fine on i386 and amd64-*-freebsd.  It even passes
if I set FreeBSD's memory allocator in a debug mode.

Comment 14 MC 2006-10-16 21:28:37 UTC
Sorry for my silence...
I have the same error with source code of comment #12 always with :
gcc version 4.1.2 20060901 (prerelease) (Debian 4.1.1-13)

I'm downloading svn snapshot...

Comment 15 Paul Thomas 2006-10-17 12:43:45 UTC
I cannot persuade this to fault on any of the platforms to which I have access either. 'tis an odd one.

Paul
Comment 16 Francois-Xavier Coudert 2006-10-17 13:01:41 UTC
Hurray! I can now also reproduce this on x86_64-linux with ElectricFence. Run f951 inside gdb and preload ElectricFence (in gdb: set environment LD_PRELOAD /usr/lib64/libefence.so). The segfault backtrace is:

Program received signal SIGSEGV, Segmentation fault.
0x0000003ff2471890 in memcpy () from /lib64/tls/libc.so.6
(gdb) where
#0  0x0000003ff2471890 in memcpy () from /lib64/tls/libc.so.6
#1  0x0000000000418ab7 in gfc_copy_expr (p=0x2a98d0cf68)
    at ../../trunk/gcc/fortran/expr.c:454
#2  0x0000000000442935 in gfc_match_rvalue (result=0x7fbfffea58)
    at ../../trunk/gcc/fortran/primary.c:2005
#3  0x00000000004356f4 in match_mult_operand (result=0x7fbfffeab0)
    at ../../trunk/gcc/fortran/matchexp.c:163
#4  0x000000000043594c in match_add_operand (result=0x7fbfffeb00)
    at ../../trunk/gcc/fortran/matchexp.c:382
#5  0x0000000000435bc3 in match_level_2 (result=0x7fbfffeb48)
    at ../../trunk/gcc/fortran/matchexp.c:501
#6  0x0000000000435cfa in match_level_3 (result=0x7fbfffeba8)
    at ../../trunk/gcc/fortran/matchexp.c:572
#7  0x0000000000435e0a in match_and_operand (result=0x7fbfffebf8)
    at ../../trunk/gcc/fortran/matchexp.c:620
#8  0x000000000043602a in match_or_operand (result=0x7fbfffec38)
    at ../../trunk/gcc/fortran/matchexp.c:735
#9  0x000000000043611a in match_equiv_operand (result=0x7fbfffec80)
    at ../../trunk/gcc/fortran/matchexp.c:778
#10 0x00000000004361fb in match_level_5 (result=0x7fbfffece8)
    at ../../trunk/gcc/fortran/matchexp.c:824
#11 0x0000000000436309 in gfc_match_expr (result=0x7fbfffee88)
    at ../../trunk/gcc/fortran/matchexp.c:883
#12 0x000000000043240a in gfc_match (target=0x965976 " if ( %e")
    at ../../trunk/gcc/fortran/match.c:663
#13 0x000000000043478e in gfc_match_if (if_type=0x7fbfffeedc)
    at ../../trunk/gcc/fortran/match.c:980
Comment 17 Francois-Xavier Coudert 2006-10-30 16:46:22 UTC
The following patch fixes the problem:

Index: data.c
===================================================================
--- data.c      (revision 118134)
+++ data.c      (working copy)
@@ -155,7 +155,8 @@
       init->expr_type = EXPR_CONSTANT;
       init->ts = *ts;
       
-      dest = gfc_getmem (len);
+      dest = gfc_getmem (len + 1);
+      dest[len] = '\0';
       init->value.character.length = len;
       init->value.character.string = dest;
       /* Blank the string if we're only setting a substring.  */
Index: decl.c
===================================================================
--- decl.c      (revision 118134)
+++ decl.c      (working copy)
@@ -753,10 +753,11 @@
   slen = expr->value.character.length;
   if (len != slen)
     {
-      s = gfc_getmem (len);
+      s = gfc_getmem (len + 1);
       memcpy (s, expr->value.character.string, MIN (len, slen));
       if (len > slen)
        memset (&s[slen], ' ', len - slen);
+      s[len] = '\0';
       gfc_free (expr->value.character.string);
       expr->value.character.string = s;
       expr->value.character.length = len;
Index: expr.c
===================================================================
--- expr.c      (revision 118134)
+++ expr.c      (working copy)
@@ -1438,7 +1438,7 @@
          gfc_extract_int (p->ref->u.ss.end, &end);
          s = gfc_getmem (end - start + 1);
          memcpy (s, p->value.character.string + start, end - start);
-         s[end] = '\0';  /* TODO: C-style string for debugging.  */
+         s[end-start+1] = '\0';  /* TODO: C-style string for debugging.  */
          gfc_free (p->value.character.string);
          p->value.character.string = s;
          p->value.character.length = end - start;


Before submitting it, I'd like to audit the rest of the front-end code for problems similar to those in decl.c and data.c.
Comment 18 Francois-Xavier Coudert 2006-10-31 20:15:40 UTC
Subject: Bug 29067

Author: fxcoudert
Date: Tue Oct 31 20:15:22 2006
New Revision: 118338

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118338
Log:
	PR fortran/29067

	* decl.c (gfc_set_constant_character_len): NULL-terminate the
	character constant string.
	* data.c (create_character_intializer): Likewise.
	* expr.c (gfc_simplify_expr): NULL-terminate the substring
	character constant.
	* primary.c (match_hollerith_constant): NULL-terminate the
	character constant string.

	* gfortran.dg/pr29067.f: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr29067.f
Modified:
    trunk/gcc/fortran/data.c
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/primary.c
    trunk/gcc/testsuite/ChangeLog

Comment 19 Francois-Xavier Coudert 2006-11-03 12:29:17 UTC
Subject: Bug 29067

Author: fxcoudert
Date: Fri Nov  3 12:28:57 2006
New Revision: 118456

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118456
Log:
	PR fortran/29067

	* decl.c (gfc_set_constant_character_len): NULL-terminate the
	character constant string.
	* data.c (create_character_intializer): Likewise.
	* expr.c (gfc_simplify_expr): NULL-terminate the substring
	character constant.
	* primary.c (match_hollerith_constant): NULL-terminate the
	character constant string.

	* gfortran.dg/pr29067.f: New test.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/pr29067.f
      - copied unchanged from r118338, trunk/gcc/testsuite/gfortran.dg/pr29067.f
Modified:
    branches/gcc-4_2-branch/gcc/fortran/ChangeLog
    branches/gcc-4_2-branch/gcc/fortran/data.c
    branches/gcc-4_2-branch/gcc/fortran/decl.c
    branches/gcc-4_2-branch/gcc/fortran/expr.c
    branches/gcc-4_2-branch/gcc/fortran/primary.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

Comment 20 Francois-Xavier Coudert 2006-11-03 14:26:11 UTC
Subject: Bug 29067

Author: fxcoudert
Date: Fri Nov  3 14:25:56 2006
New Revision: 118457

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118457
Log:
	PR fortran/29067

	* decl.c (gfc_set_constant_character_len): NULL-terminate the
	character constant string.
	* data.c (create_character_intializer): Likewise.
	* expr.c (gfc_simplify_expr): NULL-terminate the substring
	character constant.
	* primary.c (match_hollerith_constant): NULL-terminate the
	character constant string.

	* gfortran.dg/pr29067.f: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/pr29067.f
      - copied unchanged from r118456, branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/pr29067.f
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/data.c
    branches/gcc-4_1-branch/gcc/fortran/decl.c
    branches/gcc-4_1-branch/gcc/fortran/expr.c
    branches/gcc-4_1-branch/gcc/fortran/primary.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 21 Francois-Xavier Coudert 2006-11-03 14:28:16 UTC
Fixed on all active branches.