https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93690

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org ---
(In reply to Florian Schiffmann from comment #0)
> Good morning,
> 
> I ran across a problem when using a Type bound assignment (TBA). I have two
> type, the type with TBA type(Inner), and type (Outer) which has inner as a
> member. If now Type(outer) is assigned to another type(outer), the Inner
> assignment is only called if it is done elementwise. The vector assignment
> does not call the type(Inner) assignment. As I understand the standard, the
> vector assignment should call the TBA element by element.
> 
> As a side note, the assignment is called if assignMe is made ELEMENTAL
> IMPURE. While nice as a work around, I can't see an obvious reason why this
> would be the correct behavior.
> 

Thanks for reporting the possible bug.

I think the standard requires the ELEMENTAL IMPURE.  In the
following x1 and x2 are the left and right hand sides of the
assignment.  d1 and d2 are the dummy arguments of the subroutine.


10.2.1.4 Defined assignment statement

A subroutine defines the defined assignment x1 = x2 if

  (1) ok
  (2) ok
  (3) ok
  (4) ok

  (5) either

     (a) the ranks of x1 and x2 match those of d1 and d2 or
     (b) the subroutine is elemental, x2 is scalar or has the same
         rank as x1, and there is no other subroutine that defines
         the assignment.

The dummy arguments are scalars, which is rank 0.  The ranks of
x1 and x2 are 1.  5a clear fails, so we fall through to 5b, which
suggests that ELEMENTAL is needed.  IMPURE is needed as you're
doing IO from assignMe.

Note, I could be wrong.

Reply via email to