Bug 49592 - [OOP] Non-polymorphic ALLOCATE with polymorphic SOURCE= rejected
Summary: [OOP] Non-polymorphic ALLOCATE with polymorphic SOURCE= rejected
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-06-30 12:56 UTC by Tobias Burnus
Modified: 2013-01-08 16:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-01-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2011-06-30 12:56:45 UTC
http://j3-fortran.org/doc/meeting/195/11-194r1.txt

According to the first round of interpretation requests (namely: J3, WG5 will follow later), the following program is valid. gfortran rejects it with:

    Allocate(y,Source=x)               ! (*)
             1        2
Error: Type of entity at (1) is type incompatible with source-expr at (2)


  Program m195_m1
    Type t
      Real c
    End Type
    Type,Extends(t) :: t2
      Real d
    End Type
    Class(t),Allocatable :: x
    Type(t),Allocatable :: y
    Allocate(x,Source=t2(1.5,-1.5))
    Allocate(y,Source=x)               ! (*)
!    ...
  End Program


Proposed edits:

[128:24] In 6.7.1.2p7, before "On successful", insert
  "If an <allocate-object> is not polymorphic and the <source-expr> is
   polymorphic with a dynamic type that differs from its declared
   type, the value provided for that <allocate-object> is the ancestor
   component of the <source-expr> that has the type of the
   <allocate-object>; otherwise, the value provided is the value of
   the <source-expr>."
[128:25-26] Replace "that of <source-expr>" with "the value provided",
            twice.
Comment 1 Dominique d'Humieres 2013-01-08 16:17:09 UTC
Any progress here?