Bug 95138 - ICE on transfer to unlimited polymorphic
Summary: ICE on transfer to unlimited polymorphic
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 11.0
: P4 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, wrong-code
Depends on:
Blocks:
 
Reported: 2020-05-14 18:09 UTC by José Rui Faustino de Sousa
Modified: 2020-06-09 14:21 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-06-09 00:00:00


Attachments
Fortran code demonstrating problems. (270 bytes, text/plain)
2020-05-14 18:09 UTC, José Rui Faustino de Sousa
Details

Note You need to log in before you can comment on or make changes to this bug.
Description José Rui Faustino de Sousa 2020-05-14 18:09:29 UTC
Created attachment 48536 [details]
Fortran code demonstrating problems.

Hi all!

ICE on 10 and 11, 9 compiles part of the code, so there is also some aspect of regression here.

Using -Wsurprising gives surprising (to me...) diagnostics.

Not sure if all the code is kosher, most likely it is not...

using:

GNU Fortran (GCC) 11.0.0 20200513 (experimental)
GNU Fortran (GCC) 10.1.1 20200513
GNU Fortran (GCC) 9.3.1 20200513

Thank you very much.

Best regards,
José Rui
Comment 1 anlauf 2020-05-14 21:00:11 UTC
A small subset of the reproducer shows that invalid code is generated:

program transfer_p
  implicit none
  integer, parameter :: n = 3
  class(*), allocatable :: o(:)
  integer               :: v(n)
  integer               :: i

  v = [(i, i=1,n)]
  allocate(o, source=v)
  print *, "size (o) =", size (o)
  print *, transfer(o, v)
end

This compiles and gives:

 size (o) =           3
           1           2           3           0           0           0

while compiling with -fdefault-integer-8 gives the correct answer:

 size (o) =                    3
                    1                    2                    3

A look at the dump appears to give some hint where to look further.
Comment 2 anlauf 2020-05-16 12:54:57 UTC
Another datapoint: inserting

  select type (o)
  type is (integer)
     print *, transfer(o, v)
  end select

prints the right thing:

           1           2           3

Also note the possibly related PR84006, where one gets an ICE on

     print *, "storage_size (o) =", storage_size (o) ! ICE

unless one places this inside a select type.
Comment 3 Dominique d'Humieres 2020-06-09 14:21:18 UTC
Confirmed from GGC7 up to master.