public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51904] New: Internal Compiler Error on size function evaluation
@ 2012-01-19 15:08 david.sagan at gmail dot com
2012-01-19 16:38 ` [Bug fortran/51904] [4.6/4.7 Regression] ICE on SIZE " burnus at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: david.sagan at gmail dot com @ 2012-01-19 15:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51904
Bug #: 51904
Summary: Internal Compiler Error on size function evaluation
Classification: Unclassified
Product: gcc
Version: 4.6.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: david.sagan@gmail.com
The following program produces an "internal compiler error" in 4.6.3. gcc 4.5
does not show the bug:
subroutine qp_draw_polyline_basic (x)
implicit none
real :: x(:), f
f = 0
print *, size(f*x)
end subroutine
Result:
mc66:~/Bmad/bmad_dist/bug> uname -a
Darwin mc66.lns.cornell.edu 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7
16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
mc66:~/Bmad/bmad_dist/bug> gfortran --version
GNU Fortran (GCC) 4.6.2
mc66:~/Bmad/bmad_dist/bug> gfortran -c bug.f90
f951: internal compiler error: Segmentation fault
Of course the workaround is easy: Just replace "size(f*x)" with "size(x)".
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/51904] [4.6/4.7 Regression] ICE on SIZE function evaluation
2012-01-19 15:08 [Bug fortran/51904] New: Internal Compiler Error on size function evaluation david.sagan at gmail dot com
@ 2012-01-19 16:38 ` burnus at gcc dot gnu.org
2012-01-19 17:11 ` burnus at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-19 16:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51904
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
CC| |burnus at gcc dot gnu.org
Known to work| |4.1.2, 4.3.4, 4.4.0, 4.5.3
Target Milestone|--- |4.6.3
Summary|Internal Compiler Error on |[4.6/4.7 Regression] ICE on
|size function evaluation |SIZE function evaluation
Known to fail| |4.6.3, 4.7.0
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-19 16:25:54 UTC ---
Invalid read of size 8
at 0x57C267: resolve_code(gfc_code*, gfc_namespace*) (resolve.c:8316)
by 0x57DE2B: gfc_resolve_blocks(gfc_code*, gfc_namespace*) (resolve.c:9038)
by 0x5819B5: resolve_code(gfc_code*, gfc_namespace*) (resolve.c:9307)
by 0x58412E: resolve_codes(gfc_namespace*) (resolve.c:13931)
That's:
resolve_transfer (gfc_code *code)
{
...
if (exp == NULL || (exp->expr_type != EXPR_VARIABLE
&& exp->expr_type != EXPR_FUNCTION))
return;
...
sym = exp->symtree->n.sym; /* <<< segfault */
The problem is that:
(gdb) p exp->symtree
$5 = (gfc_symtree *) 0x0
(gdb) p exp->value.function
$6 = {actual = 0x15fc710, name = 0xf5939f "size", isym = 0x162c0e8, esym = 0x0}
The program works with pathf95, g95, NAG f95 and gfortran 4.1 to 4.5, but
segfaults with 4.6 and 4.7
* * *
I tried the following patch [only the first part is needed] - but it fails then
later at
Invalid read of size 8
at 0x5D3E91: gfc_conv_expr_reference(gfc_se*, gfc_expr*)
(trans-expr.c:5510)
by 0x5F2686: gfc_trans_transfer(gfc_code*) (trans-io.c:2306)
by 0x5A4987: trans_code(gfc_code*, tree_node*) (trans.c:1522)
by 0x5F01E9: build_dt(tree_node*, gfc_code*) (trans-io.c:1832)
by 0x5A49A7: trans_code(gfc_code*, tree_node*) (trans.c:1494)
by 0x5CAA8A: gfc_generate_function_code(gfc_namespace*) (trans-decl.c:5329)
There, the issue is:
if (expr->expr_type == EXPR_FUNCTION
&& ((expr->value.function.esym ....
|| (!expr->value.function.esym
&& expr->symtree->n.sym->attr.pointer
Namely: If "esym" does not exist, the code assumes that the symtree is
available - but in this case one has only an "isym".
I have somehow the feeling that the error must be up-chain.
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -8303,4 +8303,5 @@ resolve_transfer (gfc_code *code)
- if (exp == NULL || (exp->expr_type != EXPR_VARIABLE
- && exp->expr_type != EXPR_FUNCTION))
+ if (exp == NULL
+ || (exp->expr_type != EXPR_VARIABLE && exp->expr_type != EXPR_FUNCTION)
+ || (exp->expr_type == EXPR_FUNCTION && exp->value.function.isym))
return;
@@ -8315,3 +8316,4 @@ resolve_transfer (gfc_code *code)
- sym = exp->symtree->n.sym;
+ sym = exp->expr_type == EXPR_FUNCTION && exp->value.function.esym
+ ? exp->value.function.esym : exp->symtree->n.sym;
ts = &sym->ts;
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/51904] [4.6/4.7 Regression] ICE on SIZE function evaluation
2012-01-19 15:08 [Bug fortran/51904] New: Internal Compiler Error on size function evaluation david.sagan at gmail dot com
2012-01-19 16:38 ` [Bug fortran/51904] [4.6/4.7 Regression] ICE on SIZE " burnus at gcc dot gnu.org
@ 2012-01-19 17:11 ` burnus at gcc dot gnu.org
2012-01-19 18:18 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-19 17:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51904
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-19 16:50:33 UTC ---
Fails:
gcc version 4.6.0 20100828 (experimental) [trunk revision 163612] (GCC)
Works:
gcc version 4.6.0 20100716 (experimental) [trunk revision 162255] (GCC)
(Note: The builds might have local patches.)
I think it's due to the patch Rev. 162648 of 2010-07-28
http://gcc.gnu.org/viewcvs?view=revision&revision=162648
That patch tries to compile-time simplify SIZE but also changes for
nonconstant-bound arrays, e.g., SIZE(X ** 2) to SIZE(X).
Possibly the additional resolution only happens if also a symtree is available?
That would be a change to gfc_build_intrinsic_call.
If one replaces
print *, size(f*x)
by
i = size(f*x)
print *, i
the program works and one finds in the dump:
i = (integer(kind=4))
MAX_EXPR <(D.1879->dim[0].ubound - D.1879->dim[0].lbound) + 1, 0>;
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/51904] [4.6/4.7 Regression] ICE on SIZE function evaluation
2012-01-19 15:08 [Bug fortran/51904] New: Internal Compiler Error on size function evaluation david.sagan at gmail dot com
2012-01-19 16:38 ` [Bug fortran/51904] [4.6/4.7 Regression] ICE on SIZE " burnus at gcc dot gnu.org
2012-01-19 17:11 ` burnus at gcc dot gnu.org
@ 2012-01-19 18:18 ` jakub at gcc dot gnu.org
2012-01-19 20:47 ` burnus at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-01-19 18:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51904
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
CC| |jakub at gcc dot gnu.org
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/51904] [4.6/4.7 Regression] ICE on SIZE function evaluation
2012-01-19 15:08 [Bug fortran/51904] New: Internal Compiler Error on size function evaluation david.sagan at gmail dot com
` (2 preceding siblings ...)
2012-01-19 18:18 ` jakub at gcc dot gnu.org
@ 2012-01-19 20:47 ` burnus at gcc dot gnu.org
2012-01-19 22:30 ` burnus at gcc dot gnu.org
2012-01-19 22:34 ` burnus at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-19 20:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51904
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-19 20:22:43 UTC ---
Author: burnus
Date: Thu Jan 19 20:22:33 2012
New Revision: 183310
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183310
Log:
2012-01-19 Tobias Burnus <burnus@net-b.de>
PR fortran/51904
* expr.c (gfc_build_intrinsic_call): Also set the symtree.
2012-01-19 Tobias Burnus <burnus@net-b.de>
PR fortran/51904
* gfortran.dg/intrinsic_size_2.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/intrinsic_size_2.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/expr.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/51904] [4.6/4.7 Regression] ICE on SIZE function evaluation
2012-01-19 15:08 [Bug fortran/51904] New: Internal Compiler Error on size function evaluation david.sagan at gmail dot com
` (3 preceding siblings ...)
2012-01-19 20:47 ` burnus at gcc dot gnu.org
@ 2012-01-19 22:30 ` burnus at gcc dot gnu.org
2012-01-19 22:34 ` burnus at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-19 22:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51904
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-19 22:21:47 UTC ---
Author: burnus
Date: Thu Jan 19 22:21:43 2012
New Revision: 183314
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183314
Log:
2012-01-19 Tobias Burnus <burnus@net-b.de>
PR fortran/51904
*expr.c (gfc_build_intrinsic_call): Also set the symtree.
2012-01-19 Tobias Burnus <burnus@net-b.de>
PR fortran/51904
* gfortran.dg/intrinsic_size_2.f90: New.
Added:
branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/intrinsic_size_2.f90
Modified:
branches/gcc-4_6-branch/gcc/fortran/ChangeLog
branches/gcc-4_6-branch/gcc/fortran/expr.c
branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/51904] [4.6/4.7 Regression] ICE on SIZE function evaluation
2012-01-19 15:08 [Bug fortran/51904] New: Internal Compiler Error on size function evaluation david.sagan at gmail dot com
` (4 preceding siblings ...)
2012-01-19 22:30 ` burnus at gcc dot gnu.org
@ 2012-01-19 22:34 ` burnus at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-19 22:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51904
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-19 22:26:26 UTC ---
FIXED on the trunk (4.7) and on the 4.6 branch.
David, thanks for the bug report!
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-01-19 22:26 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-19 15:08 [Bug fortran/51904] New: Internal Compiler Error on size function evaluation david.sagan at gmail dot com
2012-01-19 16:38 ` [Bug fortran/51904] [4.6/4.7 Regression] ICE on SIZE " burnus at gcc dot gnu.org
2012-01-19 17:11 ` burnus at gcc dot gnu.org
2012-01-19 18:18 ` jakub at gcc dot gnu.org
2012-01-19 20:47 ` burnus at gcc dot gnu.org
2012-01-19 22:30 ` burnus at gcc dot gnu.org
2012-01-19 22:34 ` 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).