public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/46060] New: gfortran crash when referencing procedure pointer
@ 2010-10-17 19:58 sjbespa at comcast dot net
2010-10-18 2:18 ` [Bug fortran/46060] " kargl at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: sjbespa at comcast dot net @ 2010-10-17 19:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46060
Summary: gfortran crash when referencing procedure pointer
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: sjbespa@comcast.net
Created attachment 22072
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22072
module test_1.f90 which is referenced in the bug report
Compiling the module below causes a segmentation fault.
gfortran -c test_1.f90
test_1.f90: In function ‘test_subroutine’:
test_1.f90:20:0: internal compiler error: Segmentation fault
the crash occurs in last week's 4.6 trunk and 4.5.
========
gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin10.3.0/4.5.1/lto-wrapper
Target: x86_64-apple-darwin10.3.0
Configured with: ../gcc-4_5-branch/configure --prefix=/usr/local/gfortran
--enable-languages=c,c++,fortran
--with-gmp=/Users/fx/devel/gcc/ibin45/../irun45 --enable-bootstrap
--with-included-gettext --with-arch=nocona --with-tune=generic
Thread model: posix
gcc version 4.5.1 20100506 (prerelease) (GCC)
=========
/volumes/dev/gfortran-4.6-trunk/bin/gfortran -v
Using built-in specs.
COLLECT_GCC=/volumes/dev/gfortran-4.6-trunk/bin/gfortran
COLLECT_LTO_WRAPPER=/Volumes/dev/gfortran-4.6-trunk/bin/../libexec/gcc/x86_64-apple-darwin10/4.6.0/lto-wrapper
Target: x86_64-apple-darwin10
Configured with: ../gfortran-4.6-src/configure
--prefix=/volumes/dev/gfortran-4.6-trunk --enable-languages=fortran
--host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10
--target=x86_64-apple-darwin10
Thread model: posix
gcc version 4.6.0 20101013 (experimental) (GCC)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46060] gfortran crash when referencing procedure pointer
2010-10-17 19:58 [Bug fortran/46060] New: gfortran crash when referencing procedure pointer sjbespa at comcast dot net
@ 2010-10-18 2:18 ` kargl at gcc dot gnu.org
2010-10-18 6:43 ` burnus at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu.org @ 2010-10-18 2:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46060
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
Severity|critical |normal
--- Comment #1 from kargl at gcc dot gnu.org 2010-10-18 02:17:48 UTC ---
The following patch allows your code to compile, but
I have no idea if it is the correct fix.
Index: trans-expr.c
===================================================================
--- trans-expr.c (revision 165533)
+++ trans-expr.c (working copy)
@@ -5675,7 +5675,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1
gfc_conv_expr (&rse, expr2);
/* Stabilize a string length for temporaries. */
- if (expr2->ts.type == BT_CHARACTER)
+ if (expr2->ts.type == BT_CHARACTER && rse.string_length)
string_length = gfc_evaluate_now (rse.string_length, &rse.pre);
else
string_length = NULL_TREE;
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46060] gfortran crash when referencing procedure pointer
2010-10-17 19:58 [Bug fortran/46060] New: gfortran crash when referencing procedure pointer sjbespa at comcast dot net
2010-10-18 2:18 ` [Bug fortran/46060] " kargl at gcc dot gnu.org
@ 2010-10-18 6:43 ` burnus at gcc dot gnu.org
2010-10-18 9:48 ` janus at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-10-18 6:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46060
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-10-18 06:42:42 UTC ---
(In reply to comment #1)
> The following patch allows your code to compile, but
> I have no idea if it is the correct fix.
I have the feeling that it is not the best fix. The string lengths are known at
the compile time - thus, rse.string_length should be defined. I wonder whether
something goes wrong either in resolve_procedure_interface, or in
add_hidden_procptr_result or in ...?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46060] gfortran crash when referencing procedure pointer
2010-10-17 19:58 [Bug fortran/46060] New: gfortran crash when referencing procedure pointer sjbespa at comcast dot net
2010-10-18 2:18 ` [Bug fortran/46060] " kargl at gcc dot gnu.org
2010-10-18 6:43 ` burnus at gcc dot gnu.org
@ 2010-10-18 9:48 ` janus at gcc dot gnu.org
2010-10-18 11:44 ` [Bug fortran/46060] [F03] procedure pointer component referenced without argument list janus at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2010-10-18 9:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46060
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-invalid-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2010.10.18 09:48:42
Ever Confirmed|0 |1
--- Comment #3 from janus at gcc dot gnu.org 2010-10-18 09:48:42 UTC ---
Confirmed. Here is a slightly reduced test case:
implicit none
abstract interface
function name_func (ivar) result (res)
integer, intent(in) :: ivar
character(len=8) :: res
end function name_func
end interface
type var_type
procedure(name_func), nopass, pointer :: name
end type var_type
type(var_type) :: vars
character(len=8) name
name = vars%name ! invalid !!!
end
This, like the original code, is invalid and gives an ICE. Changing the invalid
line to something like
name = vars%name(3)
makes the ICE go away.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46060] [F03] procedure pointer component referenced without argument list
2010-10-17 19:58 [Bug fortran/46060] New: gfortran crash when referencing procedure pointer sjbespa at comcast dot net
` (2 preceding siblings ...)
2010-10-18 9:48 ` janus at gcc dot gnu.org
@ 2010-10-18 11:44 ` janus at gcc dot gnu.org
2010-10-18 20:48 ` janus at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2010-10-18 11:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46060
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|gfortran crash when |[F03] procedure pointer
|referencing procedure |component referenced
|pointer |without argument list
--- Comment #4 from janus at gcc dot gnu.org 2010-10-18 11:44:40 UTC ---
Here is another variation which causes a different ICE:
implicit none
type var_type
procedure(integer), nopass, pointer :: ppc
end type var_type
type(var_type) :: vars
integer :: i
i = vars%ppc
end
internal compiler error: in fold_convert_loc, at fold-const.c:1899
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46060] [F03] procedure pointer component referenced without argument list
2010-10-17 19:58 [Bug fortran/46060] New: gfortran crash when referencing procedure pointer sjbespa at comcast dot net
` (3 preceding siblings ...)
2010-10-18 11:44 ` [Bug fortran/46060] [F03] procedure pointer component referenced without argument list janus at gcc dot gnu.org
@ 2010-10-18 20:48 ` janus at gcc dot gnu.org
2010-10-21 11:32 ` janus at gcc dot gnu.org
2010-10-21 11:35 ` janus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2010-10-18 20:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46060
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |janus at gcc dot gnu.org
|gnu.org |
--- Comment #5 from janus at gcc dot gnu.org 2010-10-18 20:48:26 UTC ---
Here is a preliminary patch:
Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c (revision 165600)
+++ gcc/fortran/primary.c (working copy)
@@ -1883,13 +1883,20 @@ gfc_match_varspec (gfc_expr *primary, int equiv_fl
if (component->attr.proc_pointer && ppc_arg
&& !gfc_matching_procptr_assignment)
{
+ /* Procedure pointer component call: Look for argument list. */
m = gfc_match_actual_arglist (sub_flag,
&primary->value.compcall.actual);
if (m == MATCH_ERROR)
return MATCH_ERROR;
- if (m == MATCH_YES)
- primary->expr_type = EXPR_PPC;
+ if (m == MATCH_NO)
+ {
+ gfc_error ("Procedure pointer component '%s' requires an "
+ "argument list at %C", component->name);
+ return MATCH_ERROR;
+ }
+
+ primary->expr_type = EXPR_PPC;
break;
}
It rejects the test cases in comment #0, #3 and #4 with the proper error
message, but is otherwise untested.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46060] [F03] procedure pointer component referenced without argument list
2010-10-17 19:58 [Bug fortran/46060] New: gfortran crash when referencing procedure pointer sjbespa at comcast dot net
` (4 preceding siblings ...)
2010-10-18 20:48 ` janus at gcc dot gnu.org
@ 2010-10-21 11:32 ` janus at gcc dot gnu.org
2010-10-21 11:35 ` janus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2010-10-21 11:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46060
--- Comment #6 from janus at gcc dot gnu.org 2010-10-21 11:31:58 UTC ---
Author: janus
Date: Thu Oct 21 11:31:55 2010
New Revision: 165769
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=165769
Log:
2010-10-21 Janus Weil <janus@gcc.gnu.org>
PR fortran/46060
* match.h (gfc_matching_ptr_assignment): New global variable to indicate
we're currently matching a (non-proc-)pointer assignment.
* decl.c (match_pointer_init): Set it.
* match.c (gfc_match_pointer_assignment): Ditto.
* primary.c (matching_actual_arglist): New global variable to indicate
we're currently matching an actual argument list.
(gfc_match_actual_arglist): Set it.
(gfc_match_varspec): Reject procedure pointer component calls with
missing argument list.
2010-10-21 Janus Weil <janus@gcc.gnu.org>
PR fortran/46060
* gfortran.dg/proc_ptr_comp_25.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/proc_ptr_comp_25.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/decl.c
trunk/gcc/fortran/match.c
trunk/gcc/fortran/match.h
trunk/gcc/fortran/primary.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46060] [F03] procedure pointer component referenced without argument list
2010-10-17 19:58 [Bug fortran/46060] New: gfortran crash when referencing procedure pointer sjbespa at comcast dot net
` (5 preceding siblings ...)
2010-10-21 11:32 ` janus at gcc dot gnu.org
@ 2010-10-21 11:35 ` janus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2010-10-21 11:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46060
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #7 from janus at gcc dot gnu.org 2010-10-21 11:35:05 UTC ---
Fixed with r165769. Closing.
Thanks for the report, Stephen!
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-10-21 11:35 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-17 19:58 [Bug fortran/46060] New: gfortran crash when referencing procedure pointer sjbespa at comcast dot net
2010-10-18 2:18 ` [Bug fortran/46060] " kargl at gcc dot gnu.org
2010-10-18 6:43 ` burnus at gcc dot gnu.org
2010-10-18 9:48 ` janus at gcc dot gnu.org
2010-10-18 11:44 ` [Bug fortran/46060] [F03] procedure pointer component referenced without argument list janus at gcc dot gnu.org
2010-10-18 20:48 ` janus at gcc dot gnu.org
2010-10-21 11:32 ` janus at gcc dot gnu.org
2010-10-21 11:35 ` janus 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).