public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/58786] New: module function with passed character array of explicit length causes an ICE
@ 2013-10-18 13:56 stefan.mauerberger at gmail dot com
2013-10-18 15:10 ` [Bug fortran/58786] " burnus at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: stefan.mauerberger at gmail dot com @ 2013-10-18 13:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58786
Bug ID: 58786
Summary: module function with passed character array of
explicit length causes an ICE
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: stefan.mauerberger at gmail dot com
Hello There!
Assume a module function called "array_to_string()" whose return value is a
string. The length of the returned character is defined by the passed dummy
argument named "array" which is a character array of explicit length.
The length of the returned character shall be determined by
SUM(LEN_TRIM(array)). Well, invoking the elemental function LEN_TRIM(array)
causes an internal compiler error.
Please see the following example code. I know, it is tricky to explain:
> MODULE string_utilities_mod
>
> CONTAINS
>
> FUNCTION array_to_string(array) RESULT(str)
> CHARACTER(LEN=8) :: array(:)
> ! CHARACTER(LEN=*) :: array(:) ! Does not cause an ICE
> CHARACTER(LEN=SUM(LEN_TRIM(array))+1) :: str ! LEN_TRIM() is causing the ICE
>
> WRITE(str,*) array(:) ! Imagine some fancy code
>
> END FUNCTION array_to_string
>
> END MODULE string_utilities_mod
>
> PROGRAM test
> USE string_utilities_mod
>
> ! Just the invocation of array_to_string() causes an internal compiler error
> PRINT *, array_to_string(['aaaaaaaa','bbbbbbbb'])
>
> CONTAINS
>
> ! Everything works fine if array_to_string() is defined here
>
> END PROGRAM test
The above example has been tested with:
* Ifort 12.1 => ok
* nagfor 5.3 => ok
* pgfortran 13.8 => ok
However:
* gfortran 4.4.5 => ICE
* gfortran 4.7.2 => ICE
* grfotran 4.8.1 => ICE
* gfortran 4.9. => ICE
Cheers, Stefan
bug.f90: In function ‘test’:
bug.f90:20:0: internal compiler error: Segmentation fault
PRINT *, array_to_string(['aaaaaaaa','bbbbbbbb'])
^
0x9ad52f crash_signal
../../gcc_trunk_src/gcc/toplev.c:335
0x7b3388 contains_struct_check
../../gcc_trunk_src/gcc/tree.h:2787
0x7b3388 size_binop_loc(unsigned int, tree_code, tree_node*, tree_node*)
../../gcc_trunk_src/gcc/fold-const.c:1492
0x81cff8 gimplify_compound_lval
../../gcc_trunk_src/gcc/gimplify.c:2214
0x815ff9 gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:7631
0x822e15 gimplify_addr_expr
../../gcc_trunk_src/gcc/gimplify.c:5073
0x8162be gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:7725
0x81ef49 gimplify_call_expr
../../gcc_trunk_src/gcc/gimplify.c:2645
0x815cb8 gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:7650
0x816a49 gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:8323
0x821f88 gimplify_modify_expr
../../gcc_trunk_src/gcc/gimplify.c:4772
0x815e64 gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:7679
0x81a196 gimplify_stmt(tree_node**, gimple_statement_d**)
../../gcc_trunk_src/gcc/gimplify.c:5613
0x81703b gimplify_statement_list
../../gcc_trunk_src/gcc/gimplify.c:1535
0x81703b gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:8068
0x81a196 gimplify_stmt(tree_node**, gimple_statement_d**)
../../gcc_trunk_src/gcc/gimplify.c:5613
0x817f7a gimplify_and_add
../../gcc_trunk_src/gcc/gimplify.c:339
0x817f7a gimplify_loop_expr
../../gcc_trunk_src/gcc/gimplify.c:1509
0x817f7a gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:7854
0x81a196 gimplify_stmt(tree_node**, gimple_statement_d**)
../../gcc_trunk_src/gcc/gimplify.c:5613
>From gcc-bugs-return-432132-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Oct 18 15:05:59 2013
Return-Path: <gcc-bugs-return-432132-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 30007 invoked by alias); 18 Oct 2013 15:05:59 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 29960 invoked by uid 48); 18 Oct 2013 15:05:56 -0000
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/58787] New: ICE (error recovery) in check_proc_interface
Date: Fri, 18 Oct 2013 15:05:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: error-recovery, ice-on-invalid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: burnus at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter cc dependson
Message-ID: <bug-58787-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01276.txt.bz2
Content-length: 1588
http://gcc.gnu.org/bugzilla/show_bug.cgi?idX787
Bug ID: 58787
Summary: ICE (error recovery) in check_proc_interface
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Keywords: error-recovery, ice-on-invalid-code
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
CC: stefan.mauerberger at gmail dot com
Depends on: 58786
+++ This bug was initially created as a clone of Bug #58786 +++
The following variant of the reduced test case gives an ICE:
Error: Procedure 'array_to_string' at (1) is already defined at (2)
...
Error: Expecting END SUBROUTINE statement at (1)
f951: internal compiler error: Segmentation fault
0xa0129f crash_signal
../../gcc/toplev.c:335
0x5e84e0 check_proc_interface
../../gcc/fortran/resolve.c:143
0x5f9c88 resolve_procedure_interface
../../gcc/fortran/resolve.c:206
MODULE string_utilities_mod
CONTAINS
FUNCTION array_to_string(array) RESULT(str)
CHARACTER(LEN=1) :: array(1)
CHARACTER(LEN=SUM(LEN_TRIM(array))) :: str
END FUNCTION array_to_string
END MODULE string_utilities_mod
subroutine test
USE string_utilities_mod
character(len=1) :: x
character(len=1) :: y(1)
x = array_to_string(y)
contains
FUNCTION array_to_string(array) RESULT(str)
CHARACTER(LEN=1) :: array(1)
CHARACTER(LEN=SUM(LEN_TRIM(array))) :: str
END FUNCTION array_to_string
END subroutine test
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug fortran/58786] module function with passed character array of explicit length causes an ICE
2013-10-18 13:56 [Bug fortran/58786] New: module function with passed character array of explicit length causes an ICE stefan.mauerberger at gmail dot com
@ 2013-10-18 15:10 ` burnus at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-10-18 15:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58786
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-10-18
CC| |burnus at gcc dot gnu.org
Ever confirmed|0 |1
Known to fail| |4.1.2, 4.3.4, 4.8.2, 4.9.0
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Confirmed. Simpler test case below (especially, it is way simpler in terms of
-fdump-tree-original). For debugging, one could also place the module into a
different file.
MODULE string_utilities_mod
CONTAINS
FUNCTION array_to_string(array) RESULT(str)
CHARACTER(LEN=1) :: array(1)
CHARACTER(LEN=SUM(LEN_TRIM(array))) :: str
END FUNCTION array_to_string
END MODULE string_utilities_mod
subroutine test
USE string_utilities_mod
character(len=1) :: x
character(len=1) :: y(1)
x = array_to_string(y)
END subroutine test
If one places the module function as internal function into "test", it works.
Looking at the -fdump-tree-original, nothing stands out which looks suspicious
(also not in the direct comparison between module vs. internal function).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-10-18 15:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-18 13:56 [Bug fortran/58786] New: module function with passed character array of explicit length causes an ICE stefan.mauerberger at gmail dot com
2013-10-18 15:10 ` [Bug fortran/58786] " burnus at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).