Bug 18481 - [g77 regression] ICE with assigned integer variable format
[g77 regression] ICE with assigned integer variable format
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.0.0
: P2 normal
: ---
Assigned To: Not yet assigned to anyone
: ice-on-valid-code
: 21199 (view as bug list)
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2004-11-14 20:36 UTC by Thomas Koenig
Modified: 2005-07-07 09:56 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-03-26 17:47:01


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2004-11-14 20:37:00 UTC
This looks a lot like PR18023, but with WRITE instead of PRINT,
and the ICE is different from PR18476.

$ gfortran -v
Reading specs from /home/ig25/lib/gcc/i686-pc-linux-gnu/4.0.0/specs
Configured with: ../gcc/configure --prefix=/home/ig25
--enable-languages=c,c++,f95 : (reconfigured) ../gcc/configure
--prefix=/home/ig25 --with-gcc-version-trigger=/home/ig25/gcc/gcc/version.c
--enable-languages=c,c++,f95 --no-create --no-recursion
Thread model: posix
gcc version 4.0.0 20041114 (experimental)
$ cat format-int.f90
program internal
  integer k
  character(len=80) chr
  read(chr,k)
end program internal
$ gfortran format-int.f90
format-int.f90: In function 'MAIN__':
format-int.f90:4: internal compiler error: in gfc_add_modify_expr, at
fortran/trans.c:154
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Andrew Pinski 2004-11-14 22:25:32 UTC
Confirmed.
Looks like NIST f77 has the same ICE (from PR 17423):
FM020.f:177: internal compiler error: in gfc_add_modify_expr, at fortran/trans.c:154
FM311.f:401: internal compiler error: in gfc_add_modify_expr, at fortran/trans.c:154
FM328.f:465: internal compiler error: in gfc_add_modify_expr, at fortran/trans.c:154
Comment 2 Thomas Koenig 2004-12-04 10:37:09 UTC
This does indeed appear to be the problem
with quite a few failing NIST tests.  Here's
a reduced testcase from NIST 111.  The test case
in question has the comment

C*****    -  USE AS A FORMAT AN INTEGER VARIABLE WHOSE VALUE  10.3      02280111
C*****       IS ASSIGNED USING AN ASSIGNMENT STATEMENT.       12.4(2)   02290111

so I guess this must be legal.  It also works with g77.

$ cat assign.f
      program main
      assign 9000 to i
      print i,3.14
 9000 format ('real value = ', g12.5)
      end
$ g77 assign.f && ./a.out
real value =   3.1400
$ gfortran assign.f
 In file assign.f:2

      assign 9000 to i
                                                                       1
Warning: Obsolete: ASSIGN statement at (1)
assign.f: In function 'MAIN__':
assign.f:2: internal compiler error: in gfc_add_modify_expr, at fortran/trans.c:154
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Same error for print instead of write.
Comment 3 Thomas Koenig 2005-04-01 11:45:34 UTC
No write or print statement is necessary:

$ cat assign.f90
      program main
      assign 1000 to i
 1000 format (A)
      end
$ gfortran assign.f90
$ gfortran -fdump-parse-tree assign.f90
 In file assign.f90:2

      assign 1000 to i
                     1
Warning: Obsolete: ASSIGN statement at (1)

        Namespace: A-H: (REAL 4) I-N: (INTEGER 4) O-Z: (REAL 4)
        symtree: i  Ambig 0
        symbol i (INTEGER 4)(VARIABLE UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC
IMPLICIT-TYPE)

        symtree: main  Ambig 0
        symbol main (UNKNOWN 0)(PROGRAM UNKNOWN-INTENT UNKNOWN-ACCESS UNKNOWN-PROC)


      LABEL ASSIGN i 1000

assign.f90: In function 'MAIN__':
assign.f90:2: internal compiler error: in gfc_add_modify_expr, at
fortran/trans.c:152
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
$
$ gfortran -v
Using built-in specs.
Target: ia64-unknown-linux-gnu
Configured with: ../gcc-4.1-20050327/configure --prefix=/home/zfkts
--enable-languages=c,f95
Thread model: posix
gcc version 4.1.0 20050327 (experimental)
Comment 4 Andrew Pinski 2005-04-25 00:30:47 UTC
*** Bug 21199 has been marked as a duplicate of this bug. ***
Comment 5 fengwang 2005-05-25 10:45:09 UTC
Issues (#2, #3) related ASSIGN statement should be fixed by
http://gcc.gnu.org/ml/fortran/2005-05/msg00054.html [committed].

Issue in the description should be fixed by
http://gcc.gnu.org/ml/fortran/2005-05/msg00280.html [under reviewing].
Comment 6 Andrew Pinski 2005-06-06 00:43:46 UTC
The example in comment #0, I get the following error:
 In file t.f:4

  read(chr,k)
          1
Error: Variable 'k' has not been assigned a format label at (1)
Comment 7 fengwang 2005-07-07 09:56:07 UTC
(In reply to comment #6)
> The example in comment #0, I get the following error:
>  In file t.f:4
>   read(chr,k)
>           1
> Error: Variable 'k' has not been assigned a format label at (1)

Fixed. They are all fixed by:

http://gcc.gnu.org/ml/fortran/2005-05/msg00054.html