public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51284] New: [OOP] CLASS and VALUE attribute: No copy to temporary done
@ 2011-11-23 16:44 burnus at gcc dot gnu.org
  2011-11-23 16:47 ` [Bug fortran/51284] " burnus at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-11-23 16:44 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51284

             Bug #: 51284
           Summary: [OOP] CLASS and VALUE attribute: No copy to temporary
                    done
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: janus@gcc.gnu.org


The following program fails in several ways. As written, the program fails as
"test" modifies the value of a%i - but it shouldn't:

"A present dummy argument with the VALUE attribute becomes argument associated
with a definable anonymous data object whose initial value is the value of the
actual argument." (12.5.2.3 Argument association).

If one uncomments "test2", it fails with:
  Error: VALUE attribute conflicts with DIMENSION attribute at (1)
However, in Fortran 2008 this restriction is not present:

C557 An entity with the VALUE attribute shall be a dummy data object
     that is not an assumed-size array or a coarray, and does not have
     a coarray ultimate component.
C558 An entity with the VALUE attribute shall not have the ALLOCATABLE,
     INTENT (INOUT), INTENT (OUT), POINTER, or VOLATILE attributes.

Additionally, with the current polymorphic array draft patch the
  b(:)%i  (in "b(:)%i = 8" and "any(b(:)%i /= 8")
causes an ICE (segfault). Doing a "do i=1,8; b(i)%i = 8; done" had a similar
problem.

Finally, I think polymorphic arrays suffer from the same issue as scalar
polymorphic arrays.


Note: A deep copy has to be done, which takes the allocatable components into
account.


module m
  type t
    integer :: i
  end type t
contains
  subroutine test(x)
    class(t), VALUE :: x
    x%i = 5
  end subroutine test
!  subroutine test2(x)
!    class(t), VALUE :: x(:)
!    x(:)%i = 99
!  end subroutine test2
end module m

use m
class(t), allocatable :: a, b(:)
allocate ( t :: a, b(5))
a%i = 2
!b(:)%i = 8
call test(a)
!call test2(b)
if (a%i /= 2) call abort ()
!if (any(b(:)%i /= 8)) call abort ()
end


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

* [Bug fortran/51284] [OOP] CLASS and VALUE attribute: No copy to temporary done
  2011-11-23 16:44 [Bug fortran/51284] New: [OOP] CLASS and VALUE attribute: No copy to temporary done burnus at gcc dot gnu.org
@ 2011-11-23 16:47 ` burnus at gcc dot gnu.org
  2011-12-09 21:27 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-11-23 16:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51284

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-11-23 16:40:57 UTC ---
(In reply to comment #0)
> If one uncomments "test2", it fails with:
>   Error: VALUE attribute conflicts with DIMENSION attribute at (1)
> However, in Fortran 2008 this restriction is not present:
> 
> C558 An entity with the VALUE attribute shall not have the ALLOCATABLE,
>      INTENT (INOUT), INTENT (OUT), POINTER, or VOLATILE attributes.

In Fortran 2003:

"C527 (R501) If the VALUE attribute is specified, the PARAMETER, EXTERNAL,
POINTER, ALLOCATABLE, DIMENSION, VOLATILE, INTENT(INOUT), or INTENT(OUT)
attribute shall not be specified."

Note that the VALUE attribute is now allowed for EXTERNAL, e.g.
  subroutine foo(x)
    procedure(), VALUE :: x

As one may not modify "x" (only if it had a pointer attribute, but that's not
allowed), it does not affect the code generation.


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

* [Bug fortran/51284] [OOP] CLASS and VALUE attribute: No copy to temporary done
  2011-11-23 16:44 [Bug fortran/51284] New: [OOP] CLASS and VALUE attribute: No copy to temporary done burnus at gcc dot gnu.org
  2011-11-23 16:47 ` [Bug fortran/51284] " burnus at gcc dot gnu.org
@ 2011-12-09 21:27 ` burnus at gcc dot gnu.org
  2011-12-11 13:31 ` burnus at gcc dot gnu.org
  2015-10-09 21:43 ` dominiq at lps dot ens.fr
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-12-09 21:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51284

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-12-09 21:20:08 UTC ---
Created attachment 26036
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26036
symbol.c part of the patch: Allow DIMENSION+VALUE with -std=f2008

First patch: Allow DIMENSION with VALUE.

TODO:
- Handle dimension in trans*.c (currently, it will ICE)
- Handle the "copy in" for derived types and class (both scalar and array)


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

* [Bug fortran/51284] [OOP] CLASS and VALUE attribute: No copy to temporary done
  2011-11-23 16:44 [Bug fortran/51284] New: [OOP] CLASS and VALUE attribute: No copy to temporary done burnus at gcc dot gnu.org
  2011-11-23 16:47 ` [Bug fortran/51284] " burnus at gcc dot gnu.org
  2011-12-09 21:27 ` burnus at gcc dot gnu.org
@ 2011-12-11 13:31 ` burnus at gcc dot gnu.org
  2015-10-09 21:43 ` dominiq at lps dot ens.fr
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-12-11 13:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51284

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-12-11 12:54:29 UTC ---
(In reply to comment #2)
> - Handle the "copy in" for derived types and class (both scalar and array)

For derived types: The arguments are passed by value thus it works. However, no
copying is done for allocatable components. Note: Also "( )" (=
INTRINSIC_PARENTHESES) does not work for DT w/ allocatable components.


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

* [Bug fortran/51284] [OOP] CLASS and VALUE attribute: No copy to temporary done
  2011-11-23 16:44 [Bug fortran/51284] New: [OOP] CLASS and VALUE attribute: No copy to temporary done burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-12-11 13:31 ` burnus at gcc dot gnu.org
@ 2015-10-09 21:43 ` dominiq at lps dot ens.fr
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-09 21:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-10-09
     Ever confirmed|0                           |1

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Still present at r228660.


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

end of thread, other threads:[~2015-10-09 21:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-23 16:44 [Bug fortran/51284] New: [OOP] CLASS and VALUE attribute: No copy to temporary done burnus at gcc dot gnu.org
2011-11-23 16:47 ` [Bug fortran/51284] " burnus at gcc dot gnu.org
2011-12-09 21:27 ` burnus at gcc dot gnu.org
2011-12-11 13:31 ` burnus at gcc dot gnu.org
2015-10-09 21:43 ` 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).