public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/55172] New: ICE on invalid: gfc_variable_attr(): Bad array reference
@ 2012-11-01 22:42 abensonca at gmail dot com
2012-11-02 11:07 ` [Bug fortran/55172] [4.7/4.8 Regression] [OOP] " janus at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: abensonca at gmail dot com @ 2012-11-01 22:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55172
Bug #: 55172
Summary: ICE on invalid: gfc_variable_attr(): Bad array
reference
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: abensonca@gmail.com
The following test case produces and ICE with gfortran 4.8 (r193051):
module gn
type :: ncb
end type ncb
type, public :: tn
class(ncb), allocatable, dimension(:) :: cb
end type tn
contains
integer function name(self)
implicit none
class (tn), intent(in) :: self
select type (component => self%cb(i))
end select
end function name
end module gn
$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/abenson/Galacticus/Tools/libexec/gcc/x86_64-unknown-
linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --
prefix=/home/abenson/Galacticus/Tools --enable-languages=c,c++,fortran --
disable-multilib --with-gmp=/home/abenson/Galacticus/Tools
Thread model: posix
gcc version 4.8.0 20121031 (experimental) (GCC)
$ gfortran -c bug4.F90 -o bug4.o
bug4.F90:14.13:
end module gn
1
Internal Error at (1):
gfc_variable_attr(): Bad array reference
The code is invalid because the "name" function contains "implicit none" but
the variable "i" used in:
select type (component => self%cb(i))
is not explicitly defined. If I remove the "implicit none" or explicitly
define "i" the ICE goes away.
(Reported by Janus at http://gcc.gnu.org/ml/fortran/2012-11/msg00005.html):
With 4.7 the ICE also occurs, but only after the correct error message:
select type (component => self%cb(i))
1
Error: Symbol 'i' at (1) has no IMPLICIT type
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/55172] [4.7/4.8 Regression] [OOP] ICE on invalid: gfc_variable_attr(): Bad array reference
2012-11-01 22:42 [Bug fortran/55172] New: ICE on invalid: gfc_variable_attr(): Bad array reference abensonca at gmail dot com
@ 2012-11-02 11:07 ` janus at gcc dot gnu.org
2012-11-02 12:10 ` janus at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2012-11-02 11:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55172
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-invalid-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-11-02
Summary|[OOP] ICE on invalid: |[4.7/4.8 Regression] [OOP]
|gfc_variable_attr(): Bad |ICE on invalid:
|array reference |gfc_variable_attr(): Bad
| |array reference
Ever Confirmed|0 |1
--- Comment #1 from janus at gcc dot gnu.org 2012-11-02 11:07:33 UTC ---
(In reply to comment #0)
> (Reported by Janus at http://gcc.gnu.org/ml/fortran/2012-11/msg00005.html):
> With 4.7 the ICE also occurs, but only after the correct error message:
>
> select type (component => self%cb(i))
> 1
> Error: Symbol 'i' at (1) has no IMPLICIT type
Yes, therefore it's a regression in 4.7 (ICE after error) and 4.8 (ICE only).
4.6 of course rejects it ('cleanly') with:
class(ncb), allocatable, dimension(:) :: cb
1
Fatal Error: Polymorphic array at (1) not yet supported
(Side note: The 'fatal' seems a bit strong here, but that was probably used to
suppress further error messages.)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/55172] [4.7/4.8 Regression] [OOP] ICE on invalid: gfc_variable_attr(): Bad array reference
2012-11-01 22:42 [Bug fortran/55172] New: ICE on invalid: gfc_variable_attr(): Bad array reference abensonca at gmail dot com
2012-11-02 11:07 ` [Bug fortran/55172] [4.7/4.8 Regression] [OOP] " janus at gcc dot gnu.org
@ 2012-11-02 12:10 ` janus at gcc dot gnu.org
2012-11-25 15:55 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2012-11-02 12:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55172
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pault at gcc dot gnu.org
--- Comment #2 from janus at gcc dot gnu.org 2012-11-02 12:09:50 UTC ---
I suspect the 4.8-problem of having only the ICE without a prior error message
might be due to this commit:
http://gcc.gnu.org/viewcvs?view=revision&revision=187192
I think the function 'copy_ts_from_selector_to_associate' comes too early
(namely during parsing). It tries to resolve the target expr, which should
rather wait until resolution stage!?!
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/55172] [4.7/4.8 Regression] [OOP] ICE on invalid: gfc_variable_attr(): Bad array reference
2012-11-01 22:42 [Bug fortran/55172] New: ICE on invalid: gfc_variable_attr(): Bad array reference abensonca at gmail dot com
2012-11-02 11:07 ` [Bug fortran/55172] [4.7/4.8 Regression] [OOP] " janus at gcc dot gnu.org
2012-11-02 12:10 ` janus at gcc dot gnu.org
@ 2012-11-25 15:55 ` rguenth at gcc dot gnu.org
2012-11-29 8:41 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-11-25 15:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55172
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.7.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/55172] [4.7/4.8 Regression] [OOP] ICE on invalid: gfc_variable_attr(): Bad array reference
2012-11-01 22:42 [Bug fortran/55172] New: ICE on invalid: gfc_variable_attr(): Bad array reference abensonca at gmail dot com
` (2 preceding siblings ...)
2012-11-25 15:55 ` rguenth at gcc dot gnu.org
@ 2012-11-29 8:41 ` jakub at gcc dot gnu.org
2013-01-02 12:35 ` pault at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-11-29 8:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55172
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] 10+ messages in thread
* [Bug fortran/55172] [4.7/4.8 Regression] [OOP] ICE on invalid: gfc_variable_attr(): Bad array reference
2012-11-01 22:42 [Bug fortran/55172] New: ICE on invalid: gfc_variable_attr(): Bad array reference abensonca at gmail dot com
` (3 preceding siblings ...)
2012-11-29 8:41 ` jakub at gcc dot gnu.org
@ 2013-01-02 12:35 ` pault at gcc dot gnu.org
2013-01-04 20:51 ` pault at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu.org @ 2013-01-02 12:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55172
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot |pault at gcc dot gnu.org
|gnu.org |
--- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> 2013-01-02 12:34:35 UTC ---
(In reply to comment #2)
> I suspect the 4.8-problem of having only the ICE without a prior error message
> might be due to this commit:
>
> http://gcc.gnu.org/viewcvs?view=revision&revision=187192
>
> I think the function 'copy_ts_from_selector_to_associate' comes too early
> (namely during parsing). It tries to resolve the target expr, which should
> rather wait until resolution stage!?!
This is partially correct. Unfortunately, the selector expression comes from
the parser with the ar->type == AR_UNKNOWN and it was this that
gfc_resolve_expr was putting right. As long as all the variables were declared
or had implicit types, all was well.
Th is fixed by removing the call to gfc_resolve_expr and adding explicit code,
copied from resolve_array_ref, to set the correct type. It is also
necessary/advisable to add a call to resolve the selector expression in
resolve_select_type.
I will submit a patch later today.
Cheers
Paul
PS If the index 'i' is declared, wrong code results as in pr54990.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/55172] [4.7/4.8 Regression] [OOP] ICE on invalid: gfc_variable_attr(): Bad array reference
2012-11-01 22:42 [Bug fortran/55172] New: ICE on invalid: gfc_variable_attr(): Bad array reference abensonca at gmail dot com
` (4 preceding siblings ...)
2013-01-02 12:35 ` pault at gcc dot gnu.org
@ 2013-01-04 20:51 ` pault at gcc dot gnu.org
2013-01-05 7:52 ` [Bug fortran/55172] [4.7 only] [OOP] gfc_variable_attr(): Bad array reference in SELECT TYPE pault at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu.org @ 2013-01-04 20:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55172
--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> 2013-01-04 20:50:23 UTC ---
Author: pault
Date: Fri Jan 4 20:50:15 2013
New Revision: 194916
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194916
Log:
2013-01-04 Paul Thomas <pault@gcc.gnu.org>
PR fortran/55172
* match.c (copy_ts_from_selector_to_associate): Remove call to
gfc_resolve_expr and replace it with explicit setting of the
array reference type.
* resolve.c (resolve_select_type): It is an error if the
selector is coindexed.
2013-01-04 Paul Thomas <pault@gcc.gnu.org>
PR fortran/55172
* gfortran.dg/select_type_31.f03: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/select_type_31.f03
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/match.c
trunk/gcc/fortran/resolve.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/55172] [4.7 only] [OOP] gfc_variable_attr(): Bad array reference in SELECT TYPE
2012-11-01 22:42 [Bug fortran/55172] New: ICE on invalid: gfc_variable_attr(): Bad array reference abensonca at gmail dot com
` (5 preceding siblings ...)
2013-01-04 20:51 ` pault at gcc dot gnu.org
@ 2013-01-05 7:52 ` pault at gcc dot gnu.org
2013-04-11 7:59 ` [Bug fortran/55172] [4.7 Regression] " rguenth at gcc dot gnu.org
2014-01-19 12:20 ` pault at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu.org @ 2013-01-05 7:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55172
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|4.8.0 |4.7.3
AssignedTo|pault at gcc dot gnu.org |unassigned at gcc dot
| |gnu.org
Summary|[4.7/4.8 Regression] [OOP] |[4.7 only] [OOP]
|ICE on invalid: |gfc_variable_attr(): Bad
|gfc_variable_attr(): Bad |array reference in SELECT
|array reference |TYPE
--- Comment #5 from Paul Thomas <pault at gcc dot gnu.org> 2013-01-05 07:52:31 UTC ---
I tried the best I could with 4.7 but there are quite significant divergences
with trunk, both around and downstream from the patch. The best that I could
manage was:
/svn/gcc-4_7-branch/gcc/testsuite/gfortran.dg/select_type_31.f03:16.4:
select type (component => self%cb(i) ! { dg-error "has no IMPLICIT type" }
1
Error: Unclassifiable statement at (1)
/svn/gcc-4_7-branch/gcc/testsuite/gfortran.dg/select_type_31.f03:17.7:
end select
1
Error: Expecting END FUNCTION statement at (1)
which is more opaque than the correct error followed by the internal error!
I decided, therefore, to leave the PR as 4.7 only and have unassigned myself.
In addition, I think that to call it a regression is incorrect since
polymorphic arrays were unavailable in 4.6! I have therefore removed
regression from the title.
I might be persuaded to return to this, once 4.8 is released.
Paul
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/55172] [4.7 Regression] [OOP] gfc_variable_attr(): Bad array reference in SELECT TYPE
2012-11-01 22:42 [Bug fortran/55172] New: ICE on invalid: gfc_variable_attr(): Bad array reference abensonca at gmail dot com
` (6 preceding siblings ...)
2013-01-05 7:52 ` [Bug fortran/55172] [4.7 only] [OOP] gfc_variable_attr(): Bad array reference in SELECT TYPE pault at gcc dot gnu.org
@ 2013-04-11 7:59 ` rguenth at gcc dot gnu.org
2014-01-19 12:20 ` pault at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-04-11 7:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55172
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.7.3 |4.7.4
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> 2013-04-11 07:59:29 UTC ---
GCC 4.7.3 is being released, adjusting target milestone.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/55172] [4.7 Regression] [OOP] gfc_variable_attr(): Bad array reference in SELECT TYPE
2012-11-01 22:42 [Bug fortran/55172] New: ICE on invalid: gfc_variable_attr(): Bad array reference abensonca at gmail dot com
` (7 preceding siblings ...)
2013-04-11 7:59 ` [Bug fortran/55172] [4.7 Regression] " rguenth at gcc dot gnu.org
@ 2014-01-19 12:20 ` pault at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu.org @ 2014-01-19 12:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55172
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Paul Thomas <pault at gcc dot gnu.org> ---
I think that it is best to leave this unfixed for 4.7 - see comment #5
I have therefore marked the PR as resolved.
Thanks for the report
Paul
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-01-19 12:20 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-01 22:42 [Bug fortran/55172] New: ICE on invalid: gfc_variable_attr(): Bad array reference abensonca at gmail dot com
2012-11-02 11:07 ` [Bug fortran/55172] [4.7/4.8 Regression] [OOP] " janus at gcc dot gnu.org
2012-11-02 12:10 ` janus at gcc dot gnu.org
2012-11-25 15:55 ` rguenth at gcc dot gnu.org
2012-11-29 8:41 ` jakub at gcc dot gnu.org
2013-01-02 12:35 ` pault at gcc dot gnu.org
2013-01-04 20:51 ` pault at gcc dot gnu.org
2013-01-05 7:52 ` [Bug fortran/55172] [4.7 only] [OOP] gfc_variable_attr(): Bad array reference in SELECT TYPE pault at gcc dot gnu.org
2013-04-11 7:59 ` [Bug fortran/55172] [4.7 Regression] " rguenth at gcc dot gnu.org
2014-01-19 12:20 ` pault 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).