From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5320 invoked by alias); 23 Oct 2005 13:34:11 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 5301 invoked by uid 48); 23 Oct 2005 13:34:08 -0000 Date: Sun, 23 Oct 2005 13:34:00 -0000 Message-ID: <20051023133408.5300.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/15809] ICE Using Pointer Functions In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "sven dot buijssen at math dot uni-dortmund dot de" X-SW-Source: 2005-10/txt/msg02987.txt.bz2 List-Id: ------- 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=) 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