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
Keywords: rejects-valid
Depends on:
Reported: 2011-06-30 12:56 UTC by Tobias Burnus
Modified: 2013-01-08 16:17 UTC (History)
1 user (show)

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


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

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(y,Source=x)               ! (*)
!    ...
  End Program

Proposed edits:

[128:24] In, 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",
Comment 1 Dominique d'Humieres 2013-01-08 16:17:09 UTC
Any progress here?