public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/67528] New: Wrong result with defined assignment operator and/or parenthesized expressions and allocatable components
@ 2015-09-09 17:39 mrestelli at gmail dot com
  2015-09-09 20:18 ` [Bug fortran/67528] " kargl at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: mrestelli at gmail dot com @ 2015-09-09 17:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67528
           Summary: Wrong result with defined assignment operator and/or
                    parenthesized expressions and allocatable components
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mrestelli at gmail dot com
  Target Milestone: ---

As discussed in

https://groups.google.com/d/msg/comp.lang.fortran/8q2nYfHnZfU/M9FmGgx7AQAJ

gfortran produces wrong results with the attached code (details are
included in the source)


$ gfortran --version
GNU Fortran (GCC) 6.0.0 20150907 (experimental)


module m
 implicit none

 type :: t_a
  real, allocatable :: x
 end type t_a

 interface assignment(=)
  module procedure copy_t_a
 end interface

contains

 subroutine copy_t_a(y,x)
  type(t_a), intent(in)  :: x
  type(t_a), intent(out) :: y
   allocate( y%x , source=x%x)
 end subroutine copy_t_a

end module m


program p
 use m
 implicit none

 type(t_a) :: v1

 ! Define v1
 allocate( v1%x )
 v1%x = 1.5


 ! This produces segfault
 v1 = v1
 write(*,*) "Case A: v1%x = ",v1%x ! should print 1.5

 ! This produces segfault
 !v1 = (v1)
 !write(*,*) "Case B: v1%x = ",v1%x ! should print 1.5

 ! This prints 0
 !call copy_t_a( v1 , (v1) )
 !write(*,*) "Case C: v1%x = ",v1%x ! should print 1.5

end program p


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

end of thread, other threads:[~2015-10-26 13:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-09 17:39 [Bug fortran/67528] New: Wrong result with defined assignment operator and/or parenthesized expressions and allocatable components mrestelli at gmail dot com
2015-09-09 20:18 ` [Bug fortran/67528] " kargl at gcc dot gnu.org
2015-09-09 21:46 ` kargl at gcc dot gnu.org
2015-10-25 22:39 ` dominiq at lps dot ens.fr
2015-10-26 13:49 ` 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).