public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/67431] New: ALLOCATE with SOURCE ignores overloaded assignment operator and uses intrinsic when copying values
@ 2015-09-02  5:49 alipasha.celeris at gmail dot com
  2015-09-02  8:45 ` [Bug fortran/67431] " dominiq at lps dot ens.fr
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: alipasha.celeris at gmail dot com @ 2015-09-02  5:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67431
           Summary: ALLOCATE with SOURCE ignores overloaded assignment
                    operator and uses intrinsic when copying values
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alipasha.celeris at gmail dot com
  Target Milestone: ---

Created attachment 36285
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36285&action=edit
the test file (as it appears in the comment)

The following code produces wrong results (it compiles and runs with no memory
errors)

      MODULE A_TEST_M
        TYPE :: A_TYPE
          INTEGER :: INT
          CONTAINS
          GENERIC :: ASSIGNMENT (=) => ASGN_A
          PROCEDURE, PRIVATE :: ASGN_A
        END TYPE
        CONTAINS

        ELEMENTAL SUBROUTINE ASGN_A (A, B)
          CLASS (A_TYPE), INTENT (INOUT) :: A
          CLASS (A_TYPE), INTENT (IN) :: B
          A%INT = 42
        END SUBROUTINE
      END MODULE A_TEST_M

      PROGRAM ASGN_REALLOC_TEST
        USE A_TEST_M
        TYPE (A_TYPE), ALLOCATABLE :: A(:), B(:)

        ALLOCATE (B(4))
        B(:)%INT = 765

        ALLOCATE (A, SOURCE = B)
        PRINT *, 'SIZE(A)', SIZE(A), 'A', A

        DEALLOCATE (A, B)
      END PROGRAM

The result is:

 SIZE(A)           4 A         765         765         765         765

While all A(:)%INT should be equal to 42 if the overloaded assignment operator
was used.


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

* [Bug fortran/67431] ALLOCATE with SOURCE ignores overloaded assignment operator and uses intrinsic when copying values
  2015-09-02  5:49 [Bug fortran/67431] New: ALLOCATE with SOURCE ignores overloaded assignment operator and uses intrinsic when copying values alipasha.celeris at gmail dot com
@ 2015-09-02  8:45 ` dominiq at lps dot ens.fr
  2015-09-04  9:09 ` dominiq at lps dot ens.fr
  2015-09-29 17:15 ` dominiq at lps dot ens.fr
  2 siblings, 0 replies; 4+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-09-02  8:45 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2015-09-02
     Ever confirmed|0                           |1

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
In the standard I see

6.7.1.2 Execution of an ALLOCATE statement

...

7 If SOURCE= appears, source-expr shall be conformable with allocation.
  If the value of a nondeferred length type parameter of allocate-object
  is different from the value of the corresponding type parameter of
source-expr,
  an error condition occurs. On successful allocation, if allocate-object
  and source-expr have the same rank the value of allocate-object becomes that
  of source-expr, otherwise the value of each element of allocate-object
becomes
  that of source-expr.

6.7.1.3 Allocation of allocatable variables

...

5 When an object of derived type is created by an ALLOCATE statement,
  any allocatable ultimate components have an allocation status of unallocated
  unless the SOURCE= specier appears and the corresponding component
  of the source-expr is allocated.

i.e., there is no reference to overloaded assignment in the above quotations.

IMO your expectation is wrong, the gfortran behavior is correct and this PR
should be closed as INVALID unless you are able to point to a place in the
standard that support your expectation.


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

* [Bug fortran/67431] ALLOCATE with SOURCE ignores overloaded assignment operator and uses intrinsic when copying values
  2015-09-02  5:49 [Bug fortran/67431] New: ALLOCATE with SOURCE ignores overloaded assignment operator and uses intrinsic when copying values alipasha.celeris at gmail dot com
  2015-09-02  8:45 ` [Bug fortran/67431] " dominiq at lps dot ens.fr
@ 2015-09-04  9:09 ` dominiq at lps dot ens.fr
  2015-09-29 17:15 ` dominiq at lps dot ens.fr
  2 siblings, 0 replies; 4+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-09-04  9:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
>From Damian Rouson:

NAG 6.0 ouptput:

SIZE(A) 4 A 765 765 765 765


Cray Compiler Environment (CCE) 8.3.14 output:

SIZE(A) 4 A 4*765


Portland Group 15.7-0 output:

SIZE(A)            4 A          765          765          765          765

and Andre Vehreschild told me on IRC that gfortran agrees with ifort.


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

* [Bug fortran/67431] ALLOCATE with SOURCE ignores overloaded assignment operator and uses intrinsic when copying values
  2015-09-02  5:49 [Bug fortran/67431] New: ALLOCATE with SOURCE ignores overloaded assignment operator and uses intrinsic when copying values alipasha.celeris at gmail dot com
  2015-09-02  8:45 ` [Bug fortran/67431] " dominiq at lps dot ens.fr
  2015-09-04  9:09 ` dominiq at lps dot ens.fr
@ 2015-09-29 17:15 ` dominiq at lps dot ens.fr
  2 siblings, 0 replies; 4+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-09-29 17:15 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
No feedback! closing as INVALID.


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

end of thread, other threads:[~2015-09-29 17:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-02  5:49 [Bug fortran/67431] New: ALLOCATE with SOURCE ignores overloaded assignment operator and uses intrinsic when copying values alipasha.celeris at gmail dot com
2015-09-02  8:45 ` [Bug fortran/67431] " dominiq at lps dot ens.fr
2015-09-04  9:09 ` dominiq at lps dot ens.fr
2015-09-29 17:15 ` dominiq at lps dot ens.fr

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