public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51652] New: [F03] ICE with allocatable scalars
@ 2011-12-22  4:04 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
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: davidgkinniburgh at yahoo dot co.uk @ 2011-12-22  4:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51652

             Bug #: 51652
           Summary: [F03] ICE with allocatable scalars
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: davidgkinniburgh@yahoo.co.uk


module settings

type keyword
!  character(60), allocatable :: c(:)   ! works but should it?
!  character(80), allocatable :: c(:)   ! works
   character(:), allocatable :: c(:)
end type keyword

type(keyword) :: kw(10)

contains

subroutine save_kw

!allocate(kw(1)%c(10))
allocate(character(80) :: kw(1)%c(10))

kw(1)%c(1) = 'abcd'

if (kw(1)%c(1).eq.'abcd') then  ! problem here
   print *, 'yes'
else
   print *, 'no'
endif

end subroutine save_kw

end module settings

!*************************************************************************

program ice
use settings

call save_kw

end program ice


gcc version 4.7.0 20111212 (experimental) [trunk revision 182257] (GCC)

=========================================================================
f951.exe: internal compiler error: in gfc_get_derived_type, at
fortran/trans-types.c:2401

I'm also interested in testing substrings like

if (kw(1)%c(1)(1:1).eq.'a') then ...

The above program works ok with non-deferred scalar lengths. However, it also
works when the component is assigned different lengths in the subroutine and
main body (e.g. 60 and 80) whereas Intel Fortran reports this as an error: "In
an ALLOCATE statement the type parameter values in type specification must be
the same as a corresponding nondeferred values of the objects being
allocated.".


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [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

end of thread, other threads:[~2015-08-07 20:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).