* [Bug fortran/51652] [F03] ICE with allocatable scalarstype parameter
2011-12-22 4:04 [Bug fortran/51652] New: [F03] ICE with allocatable scalars davidgkinniburgh at yahoo dot co.uk
@ 2011-12-22 8:44 ` burnus at gcc dot gnu.org
2011-12-22 9:50 ` [Bug fortran/51652] Allocate with type-spec and source-expr: check whether length type-parameter is the same is lacking burnus at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-12-22 8:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51652
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid,
| |diagnostic, wrong-code
CC| |burnus at gcc dot gnu.org
Summary|[F03] ICE with allocatable |[F03] ICE with allocatable
|scalars |scalarstype parameter
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-12-22 08:40:10 UTC ---
(In reply to comment #0)
> type keyword
> ! character(60), allocatable :: c(:) ! works but should it?
> ! character(80), allocatable :: c(:) ! works
> character(:), allocatable :: c(:)
> end type keyword
Unfortunately, deferred-length type parameters (i.e. allocatable string
lengths) are not yet supported for components of derived types. The current
version does not crash (ICE, internal compiler error) but prints an error:
character(:), allocatable :: c(:)
1
Error: Deferred-length character component 'c' at (1) is not yet supported
As this is already tracked in PR 51550, PR 47545, PR 49050, PR 51075 - and PR
45170, I ignore the issue in this PR and concentrate on your second issue.
* * *
Regarding the allocation:
character(60), allocatable :: c(:)
allocate(character(80) :: c(10))
That's invalid; currently, the value in the allocate statement is ignored by
gfortran.
The standard requires that this is diagnosed:
"If type-spec appears and the value of a type parameter it specifies differs
from the value of the corresponding nondeferred type parameter specified in the
declaration of any allocate-object, an error condition occurs. If the value of
a nondeferred length type parameter of an allocate-object differs from the
value of the corresponding type parameter of source-expr, an error condition
occurs."
Note that this cannot always diagnosed at compile time, given that also the
following is valid:
subroutine sub(n)
integer :: n
character(len=n), allocatable :: str(:)
allocate(character(n) :: str(1))
print *, len(str), size(str)
end
call sub(4)
call sub(5)
end
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/51652] Allocate with type-spec and source-expr: check whether length type-parameter is the same is lacking
2011-12-22 4:04 [Bug fortran/51652] New: [F03] ICE with allocatable scalars davidgkinniburgh at yahoo dot co.uk
2011-12-22 8:44 ` [Bug fortran/51652] [F03] ICE with allocatable scalarstype parameter burnus at gcc dot gnu.org
@ 2011-12-22 9:50 ` burnus at gcc dot gnu.org
2011-12-22 16:36 ` davidgkinniburgh at yahoo dot co.uk
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-12-22 9:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51652
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[F03] ICE with allocatable |Allocate with type-spec and
|scalarstype parameter |source-expr: check whether
| |length type-parameter is
| |the same is lacking
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-12-22 08:44:08 UTC ---
(In reply to comment #1)
> If the value of a nondeferred length type parameter of an allocate-object
> differs from the value of the corresponding type parameter of source-expr,
> an error condition occurs."
The postscripts: Remember that source-expr covers both SOURCE= and MOLD=. And I
forgot to mention that the source of the quote: Fortran 2008, "6.7.1 ALLOCATE
statement", paragraph 6.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/51652] Allocate with type-spec and source-expr: check whether length type-parameter is the same is lacking
2011-12-22 4:04 [Bug fortran/51652] New: [F03] ICE with allocatable scalars davidgkinniburgh at yahoo dot co.uk
2011-12-22 8:44 ` [Bug fortran/51652] [F03] ICE with allocatable scalarstype parameter burnus at gcc dot gnu.org
2011-12-22 9:50 ` [Bug fortran/51652] Allocate with type-spec and source-expr: check whether length type-parameter is the same is lacking burnus at gcc dot gnu.org
@ 2011-12-22 16:36 ` davidgkinniburgh at yahoo dot co.uk
2012-01-10 11:22 ` burnus at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: davidgkinniburgh at yahoo dot co.uk @ 2011-12-22 16:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51652
--- Comment #3 from David Kinniburgh <davidgkinniburgh at yahoo dot co.uk> 2011-12-22 16:21:09 UTC ---
Sorry, I wasn't up-to-date on the long history of allocatable scalars and dt
components, and hadn't checked the documentation in detail recently. Anyway
thanks for all your work on this - I greatly appreciate your effort.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/51652] Allocate with type-spec and source-expr: check whether length type-parameter is the same is lacking
2011-12-22 4:04 [Bug fortran/51652] New: [F03] ICE with allocatable scalars davidgkinniburgh at yahoo dot co.uk
` (2 preceding siblings ...)
2011-12-22 16:36 ` davidgkinniburgh at yahoo dot co.uk
@ 2012-01-10 11:22 ` burnus at gcc dot gnu.org
2012-06-29 18:20 ` mikael at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-10 11:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51652
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-10 11:22:24 UTC ---
Author: burnus
Date: Tue Jan 10 11:22:16 2012
New Revision: 183061
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183061
Log:
2012-01-10 Tobias Burnus <burnus@net-b.de>
PR fortran/51652
* resolve.c (resolve_allocate_expr): For non-deferred char
lengths, check whether type-spec matches declaration.
2012-01-10 Tobias Burnus <burnus@net-b.de>
PR fortran/51652
* gfortran.dg/allocate_with_typespec_5.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/allocate_with_typespec_5.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/resolve.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/51652] Allocate with type-spec and source-expr: check whether length type-parameter is the same is lacking
2011-12-22 4:04 [Bug fortran/51652] New: [F03] ICE with allocatable scalars davidgkinniburgh at yahoo dot co.uk
` (3 preceding siblings ...)
2012-01-10 11:22 ` burnus at gcc dot gnu.org
@ 2012-06-29 18:20 ` mikael at gcc dot gnu.org
2014-07-20 8:48 ` dominiq at lps dot ens.fr
2015-08-07 20:24 ` mikael at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: mikael at gcc dot gnu.org @ 2012-06-29 18:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51652
Mikael Morin <mikael at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikael at gcc dot gnu.org
--- Comment #5 from Mikael Morin <mikael at gcc dot gnu.org> 2012-06-29 18:19:56 UTC ---
Fixed?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/51652] Allocate with type-spec and source-expr: check whether length type-parameter is the same is lacking
2011-12-22 4:04 [Bug fortran/51652] New: [F03] ICE with allocatable scalars davidgkinniburgh at yahoo dot co.uk
` (4 preceding siblings ...)
2012-06-29 18:20 ` mikael at gcc dot gnu.org
@ 2014-07-20 8:48 ` dominiq at lps dot ens.fr
2015-08-07 20:24 ` mikael at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-07-20 8:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51652
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-07-20
Ever confirmed|0 |1
--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Fixed?
Mostly for 4.8.3, 4.9.0, and trunk (4.10.0). The test in comment 0 does not
compile with 4.8 (Deferred-length character component 'c' at (1) is not yet
supported) and, when compiled with 4.9 or 4.10, executing the code gives 'no':
'kw(1)%c(1)' is empty.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/51652] Allocate with type-spec and source-expr: check whether length type-parameter is the same is lacking
2011-12-22 4:04 [Bug fortran/51652] New: [F03] ICE with allocatable scalars davidgkinniburgh at yahoo dot co.uk
` (5 preceding siblings ...)
2014-07-20 8:48 ` dominiq at lps dot ens.fr
@ 2015-08-07 20:24 ` mikael at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-08-07 20:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51652
--- Comment #7 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Dominique d'Humieres from comment #6)
> > Fixed?
>
> Mostly for 4.8.3, 4.9.0, and trunk (4.10.0). The test in comment 0 does not
> compile with 4.8 (Deferred-length character component 'c' at (1) is not yet
> supported) and, when compiled with 4.9 or 4.10, executing the code gives
> 'no': 'kw(1)%c(1)' is empty.
Current trunk(6) and 5 branch now print 'yes'.
4.9.x prints 'no'.
^ permalink raw reply [flat|nested] 8+ messages in thread