This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/15809] ICE Using Pointer Functions
- From: "sven dot buijssen at math dot uni-dortmund dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Oct 2005 13:34:08 -0000
- Subject: [Bug fortran/15809] ICE Using Pointer Functions
- References: <bug-15809-7776@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #13 from sven dot buijssen at math dot uni-dortmund dot de 2005-10-23 13:34 -------
In the meantime with gfortran 4.0.2 and the latest CVS version of gfortran (GNU
F95 version 4.1.0 20051023 (experimental)) again both Tobi's and Erik's
testcases give ICEs, both different ones:
# Tobi's testcase
$ cat bug7.f90
SUBROUTINE A(p,LEN)
CHARACTER(LEN=LEN), DIMENSION(:), POINTER :: p
IF ( .NOT. ASSOCIATED(p) ) THEN
END IF
END SUBROUTINE A
$ gfortran bug7.f90
bug7.f90: In function 'a':
bug7.f90:3: internal compiler error: in gfc_trans_deferred_array, at
fortran/trans-array.c:4163
# Erik's testcase
$ cat bug7a.f90
SUBROUTINE A(p,LEN)
CHARACTER(LEN=LEN), DIMENSION(:), POINTER :: p
IF ( .NOT. ASSOCIATED(p) ) THEN
allocate(p(1))
END IF
END SUBROUTINE A
$ gfortran bug7a.f90
bug7a.f90: In function 'a':
bug7a.f90:1: internal compiler error: Segmentation fault
Both testcases, however, compile smoothly when replacing CHARACTER(LEN=LEN) by
something fixed, e.g. CHARACTER(LEN=5). So, assigning a fixed length is a
possible workaround for those that are affected by this bug, like I am.
Investigating this bug further one finds:
1) Tobi's testcase with assumed-length character, CHARACTER(LEN=*), compiles
smoothly as well, while Erik's testcase with CHARACTER(LEN=*) gives again
bug7a.f90: In function 'a':
bug7a.f90:1: internal compiler error: Segmentation fault
2) The problem seems to be that accessing a member of the array p, e.g. via
print *, p(1)
or via 'allocate' as in Erik's test case, causes an ICE if and if only an
assumed-length character is used. CHARACTER(LEN=<some number>) works.
3) Fixing this bug will probably also fix the ICE for the following invalid (!)
code
$ cat bug7c.f90
function foo()
character(len=*),dimension(:),pointer :: foo
allocate(foo(1))
end function
$ gfortran -c bug7c.f90
bug3.f90: In function 'foo':
bug3.f90:1: internal compiler error: Segmentation fault
while it simply gives errors with ifort 9.0 20050809
> fortcom: Error: bug3.f90, line 1: A CHARACTER function name must not be declared with an asterisk type-param-value (i.e., (LEN=*)) if the function is array-valued.
and g95 (G95 (GCC 4.0.1 (g95!) Oct 16 2005))
> Error: POINTER valued function 'foo' at (1) cannot return an assumed-length character (*)
As previously, this problem only occurs if assumed-length character is used
instead of a fixed length.
I hope this information will help tracing the error.
For sake of completeness:
$ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcccvs/configure --enable-shared
--prefix=/usr/local/gcc-4.0.x-cvs --enable-languages=c,c++,fortran
--enable-threads --enable-__cxa_atexit
Thread model: posix
gcc version 4.1.0 20051023 (experimental)
$ gfortran-4.0.2 -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.0.2/configure --enable-shared
--prefix=/usr/local/gcc-4.0.2 --enable-languages=c,c++,f95 --enable-threads
--enable-__cxa_atexit
Thread model: posix
gcc version 4.0.2
Environment:
System: Linux stingray 2.6.8-24.18-default #1 Fri Aug 19 11:56:28 UTC 2005 i686
unknown unknown GNU/Linux
Architecture: i686
glibc 2.3.4
SuSE 9.2
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
--
sven dot buijssen at math dot uni-dortmund dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sven dot buijssen at math
| |dot uni-dortmund dot de
Bug 15809 depends on bug 15326, which changed state.
Bug 15326 Summary: [4.0 only] ICE with assumed length character strings
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15326
What |Old Value |New Value
----------------------------------------------------------------------------
Status|REOPENED |NEW
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15809