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

* [Bug fortran/67528] Wrong result with defined assignment operator and/or parenthesized expressions and allocatable components
  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 ` kargl at gcc dot gnu.org
  2015-09-09 21:46 ` kargl at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-09-09 20:18 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-09-09
                 CC|                            |kargl at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from kargl at gcc dot gnu.org ---
Possible patch

https://gcc.gnu.org/ml/fortran/2015-09/msg00058.html

The essence of the issue is that the assignments
aren't being translates to the call.

v1 = v1   --> call copy_t_a(v1, (v1))
vi = (v1) --> call copy_t_a(vi, ((v1)))


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

* [Bug fortran/67528] Wrong result with defined assignment operator and/or parenthesized expressions and allocatable components
  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
  3 siblings, 0 replies; 5+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-09-09 21:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from kargl at gcc dot gnu.org ---
This bug report appears to be a related to PR59202 and
may be a duplicate.


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

* [Bug fortran/67528] Wrong result with defined assignment operator and/or parenthesized expressions and allocatable components
  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
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-25 22:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
AFAICT this PR is fixed after revision r229303.


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

* [Bug fortran/67528] Wrong result with defined assignment operator and/or parenthesized expressions and allocatable components
  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
                   ` (2 preceding siblings ...)
  2015-10-25 22:39 ` dominiq at lps dot ens.fr
@ 2015-10-26 13:49 ` dominiq at lps dot ens.fr
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-26 13:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> AFAICT this PR is fixed after revision r229303.

Well, this is not true with -O and above. If i compile the code with '-O0
-fsanitize=address,undefined' I get at run time

pr67528.f90:17: runtime error: load of null pointer of type 'real(kind=4)'
 Case A: v1%x =  -0.372548997    

and with '-O -fsanitize=address,undefined'

pr67528.f90:17: runtime error: load of null pointer of type 'real(kind=4)'
ASAN:DEADLYSIGNAL
=================================================================
==36379==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc
0x00010c738887 bp 0x000000000000 sp 0x7fff534c8130 T0)
    #0 0x10c738886 in __m_MOD_copy_t_a (a.out+0x100001886)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (a.out+0x100001886) in __m_MOD_copy_t_a
==36379==ABORTING

Program received signal SIGABRT: Process abort signal.

Backtrace for this error:
#0  0x10d4866a4
#1  0x10d485aa5
#2  0x7fff8f8aff19
Abort


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