$ cat exponent-3.f90 program main real, parameter :: n = 1024, iter=1000 real, dimension(n) :: num1,num2 call random_number(num1) real :: start do i=1,iter num2 = num1**2 end do end program main $ gfortran exponent-3.f90 exponent-3.f90:5.15: real :: start 1 Error: Unexpected data declaration statement at (1) exponent-3.f90:3.18: real, dimension(n) :: num1,num2 1 Error: Expression at (1) must be of INTEGER type exponent-3.f90:3.33: real, dimension(n) :: num1,num2 1 Error: The module or main program array 'num2' at (1) must have constant shape exponent-3.f90:3.18: real, dimension(n) :: num1,num2 1 Error: Expression at (1) must be of INTEGER type exponent-3.f90:3.28: real, dimension(n) :: num1,num2 1 Error: The module or main program array 'num1' at (1) must have constant shape exponent-3.f90:0: internal compiler error: Segmentation fault 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: i686-pc-linux-gnu Configured with: ../../gcc/trunk/configure --prefix=/home/ig25 --enable-maintainer-mode --enable-languages=c,fortran Thread model: posix gcc version 4.3.0 20070419 (experimental) The backtrace is confused, looks like a smashed stack: Error: The module or main program array 'num1' at (1) must have constant shape Program received signal SIGSEGV, Segmentation fault. 0xb7ef8103 in __gmpz_sub () from /usr/local/lib/libgmp.so.3 (gdb) bt #0 0xb7ef8103 in __gmpz_sub () from /usr/local/lib/libgmp.so.3 #1 0xb7edf840 in ?? () from /usr/local/lib/libgmp.so.3 #2 0x0860eca0 in ?? () #3 0x0000000b in ?? () #4 0x0860f508 in ?? () #5 0x00000001 in ?? () #6 0x00000001 in ?? () #7 0x00000004 in ?? () #8 0x0860eca0 in ?? () #9 0x00000000 in ?? ()
My analysis in the original bug report wasn't correct. Here is a shorter version: $ cat real-dim-2.f90 program main real :: a(2.0),b(2.0) a = b end program main $ gfortran real-dim-2.f90 real-dim-2.f90:2.12: real :: a(2.0),b(2.0) 1 Error: Expression at (1) must be of INTEGER type real-dim-2.f90:2.16: real :: a(2.0),b(2.0) 1 Error: The module or main program array 'a' at (1) must have constant shape real-dim-2.f90:2.19: real :: a(2.0),b(2.0) 1 Error: Expression at (1) must be of INTEGER type real-dim-2.f90:2.23: real :: a(2.0),b(2.0) 1 Error: The module or main program array 'b' at (1) must have constant shape real-dim-2.f90:0: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Closely related to PR 31251.
As with pr31251, I do not see the segfault here.
I attached a patch to pr31251, can someone try that and see what effect it has on this one.
In the expr for a or b, the lower bound is coming up BT_INTEGER and the upper bound is BT_REAL. Eventually we hit the error for wrong type. Then, because this fails to resolve, that is interpreted by resolve_fl_variable to mean "The module or main program array 'a' at (1) must have constant shape" when this really is not the case. In resolve_symbol, everything is tried to resolve a symbol, regardless of previously issues errors at lower levels. Might want to rethink that approach. I can not reproduce the segfault, so if I can get a backtrace it would help. I also wonder if the best way to solve this is at the matcher level and throw a syntax error when we see a period in the integer value we are expecting and be done with all the other complexities. ...
> I can not reproduce the segfault, so if I can get a backtrace it would help. Jerry, I hope this helps. Let me know if you need something else :) $> gfortran-svn -v gcc version 4.3.0 20070517 (experimental) (gdb) bt #0 0xb7e926b1 in __gmpz_sub () from /usr/lib/libgmp.so.3 #1 0x080503d6 in spec_dimen_size (as=0x887f6e0, dimen=0, result=0xbf8ade38) at ../../../gcc/gcc/fortran/array.c:1733 #2 0x08093494 in expression_rank (e=0x887ffc8) at ../../../gcc/gcc/fortran/resolve.c:3025 #3 0x08094726 in gfc_resolve_expr (e=0x887ffc8) at ../../../gcc/gcc/fortran/resolve.c:3298 #4 0x080981e0 in resolve_code (code=0x887fe48, ns=0x88451b0) at ../../../gcc/gcc/fortran/resolve.c:5158 #5 0x08097dfa in gfc_resolve_blocks (b=0x887fe08, ns=0x88451b0) at ../../../gcc/gcc/fortran/resolve.c:5091 #6 0x080981c6 in resolve_code (code=0x887f3e0, ns=0x88451b0) at ../../../gcc/gcc/fortran/resolve.c:5150 #7 0x08099bb5 in resolve_codes (ns=0x88451b0) at ../../../gcc/gcc/fortran/resolve.c:7452 #8 0x08099bf3 in gfc_resolve (ns=0x88451b0) at ../../../gcc/gcc/fortran/resolve.c:7471 #9 0x0808d69c in gfc_parse_file () at ../../../gcc/gcc/fortran/parse.c:3248 #10 0x080aea4d in gfc_be_parse_file (set_yydebug=0) at ../../../gcc/gcc/fortran/f95-lang.c:303 #11 0x082ffdf8 in toplev_main (argc=2, argv=0xbf8ae2c4) at ../../../gcc/gcc/toplev.c:1051 #12 0x080f25bf in main (argc=Cannot access memory at address 0x0 ) at ../../../gcc/gcc/main.c:35 $> gfortran-4.2 -v gcc version 4.2.1 20070517 (prerelease) (gdb) bt #0 0xb7ed46b1 in __gmpz_sub () from /usr/lib/libgmp.so.3 #1 0x0804f15d in spec_dimen_size (as=0x8611440, dimen=0, result=0xbff27cf8) at /home/daniel/svn/gcc-4.2/gcc/fortran/array.c:1735 #2 0x0808fdaf in expression_rank (e=0x8611d00) at /home/daniel/svn/gcc-4.2/gcc/fortran/resolve.c:3023 #3 0x08090f9e in gfc_resolve_expr (e=0x8611d00) at /home/daniel/svn/gcc-4.2/gcc/fortran/resolve.c:3230 #4 0x080944f4 in resolve_code (code=0x8612080, ns=0x8610ad8) at /home/daniel/svn/gcc-4.2/gcc/fortran/resolve.c:5038 #5 0x0809724d in gfc_resolve_blocks (b=0x8611af8, ns=0x8610ad8) at /home/daniel/svn/gcc-4.2/gcc/fortran/resolve.c:4973 #6 0x080944da in resolve_code (code=0x8611c40, ns=0x8610ad8) at /home/daniel/svn/gcc-4.2/gcc/fortran/resolve.c:5030 #7 0x08095e33 in gfc_resolve (ns=0x8610ad8) at /home/daniel/svn/gcc-4.2/gcc/fortran/resolve.c:7312 #8 0x0808a309 in gfc_parse_file () at /home/daniel/svn/gcc-4.2/gcc/fortran/parse.c:3222 #9 0x080ac02d in gfc_be_parse_file (set_yydebug=0) at /home/daniel/svn/gcc-4.2/gcc/fortran/f95-lang.c:303 #10 0x08310faa in toplev_main (argc=2, argv=0xbff28134) at /home/daniel/svn/gcc-4.2/gcc/toplev.c:1033 #11 0x080d893f in main (argc=Cannot access memory at address 0x0 ) at /home/daniel/svn/gcc-4.2/gcc/main.c:35
Created attachment 13575 [details] Possible patch for this problem Daniel, Please try this patch and see if eliminates the segfault. TIA
Jerry, the patch eliminates the ICE and regtests cleanly. $> cat pr31716.f90 program main real, parameter :: n = 1024, iter=1000 real, dimension(n) :: num1,num2 call random_number(num1) do i=1,iter num2 = num1**2 end do end program main $> gfortran-svn -Wall pr31760.f90 pr31760.f90:3.18: real, dimension(n) :: num1,num2 1 Error: Expression at (1) must be of INTEGER type pr31760.f90:3.33: real, dimension(n) :: num1,num2 1 Error: The module or main program array 'num2' at (1) must have constant shape pr31760.f90:3.18: real, dimension(n) :: num1,num2 1 Error: Expression at (1) must be of INTEGER type pr31760.f90:3.28: real, dimension(n) :: num1,num2 1 Error: The module or main program array 'num1' at (1) must have constant shape The messages "must have constant shape" puzzles me as N is a PARAMETER?!
> $> gfortran-svn -Wall pr31760.f90 This should of course read "gfortran-svn -Wall pr31716.f90" - the contents of the file does correspond to this PR, the file name does not ...
Have to remind myself to submit the patch. The odd messages are from trying to match and resolve other things, after failing already. I am working on a patch to try circumvent some of these. Garbage in Garbage Out though. :)
Subject: Bug number PR31716 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-05/msg01265.html
Subject: Bug 31716 Author: jvdelisle Date: Thu May 24 05:03:51 2007 New Revision: 125013 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=125013 Log: 2007-05-23 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/31716 * array.c (spec_dimen_size): Test for correct BT_INTEGER type. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/array.c
Fixed on trunk.