public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51634] New: [OOP] ICE with polymorphic operators
@ 2011-12-20 8:57 burnus at gcc dot gnu.org
2012-01-02 13:28 ` [Bug fortran/51634] " pault at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-12-20 8:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51634
Bug #: 51634
Summary: [OOP] ICE with polymorphic operators
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
Depends on: 46328, 51334
Related to PR 51334 and PR 46328, though the error message is slightly
different.
foo.f90:37:0: internal compiler error: tree check: expected function_type or
method_type, have pointer_type in gimplify_call_expr, at gimplify.c:2430
module field_module
implicit none
private
public :: field
type :: field
real, allocatable :: f(:)
contains
procedure :: multiply_real => multiply
procedure :: copy => copy_field
generic :: operator(*) => multiply_real
generic :: assignment(=) => copy
end type
contains
subroutine copy_field (lhs, rhs)
class(field), intent(inout) :: lhs
class(field), intent(in) :: rhs
lhs%f = rhs%f
end subroutine
function multiply(lhs,rhs)
class(field) ,intent(in) :: lhs
real ,intent(in) :: rhs
class(field) ,allocatable :: multiply
allocate(multiply)
multiply%f = lhs%f * rhs
end function
end module field_module
program main
use field_module
implicit none
type(field) :: f, g
real :: dt, half
dt = 7
half = 0.5
f = g * dt * half
end program main
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/51634] [OOP] ICE with polymorphic operators
2011-12-20 8:57 [Bug fortran/51634] New: [OOP] ICE with polymorphic operators burnus at gcc dot gnu.org
@ 2012-01-02 13:28 ` pault at gcc dot gnu.org
2012-01-13 22:21 ` burnus at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pault at gcc dot gnu.org @ 2012-01-02 13:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51634
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pault at gcc dot gnu.org
--- Comment #1 from Paul Thomas <pault at gcc dot gnu.org> 2012-01-02 13:28:13 UTC ---
Fixed on trunk as long as explicit allocations are inserted, as below.
I will raise a separate PR for the lack of automatic allocate on assign for
class objects with derived type components.
Thanks for the report.
Paul
module field_module
implicit none
private
public :: field
type :: field
real, allocatable :: f(:)
contains
procedure :: multiply_real => multiply
procedure :: copy => copy_field
generic :: operator(*) => multiply_real
generic :: assignment(=) => copy
end type
contains
subroutine copy_field (lhs, rhs)
class(field), intent(inout) :: lhs
class(field), intent(in) :: rhs
if (allocated (lhs%f)) deallocate (lhs%f)
allocate (lhs%f(size (rhs%f, 1)))
lhs%f = rhs%f
end subroutine
function multiply(lhs,rhs)
class(field) ,intent(in) :: lhs
real ,intent(in) :: rhs
class(field) ,allocatable :: multiply
integer :: i
allocate(multiply, source = field([(0.0, i = 1, size (lhs%f, 1))]))
multiply%f = lhs%f * rhs
end function
end module field_module
program main
use field_module
implicit none
type(field) :: f, g
real :: dt, half
allocate (g%f(2), source = [1.0, 2.0])
dt = 7
half = 0.5
f = g * dt * half
print *, f%f
end program main
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/51634] [OOP] ICE with polymorphic operators
2011-12-20 8:57 [Bug fortran/51634] New: [OOP] ICE with polymorphic operators burnus at gcc dot gnu.org
2012-01-02 13:28 ` [Bug fortran/51634] " pault at gcc dot gnu.org
@ 2012-01-13 22:21 ` burnus at gcc dot gnu.org
2012-01-18 23:00 ` pault at gcc dot gnu.org
2012-01-19 8:49 ` burnus at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-13 22:21 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51634
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-13 22:17:53 UTC ---
(In reply to comment #1)
> Fixed on trunk as long as explicit allocations are inserted, as below.
> I will raise a separate PR for the lack of automatic allocate on assign for
> class objects with derived type components.
The test case now works since the commit of PR 48351 (and thus I closed PR
51733). The following allocates of comment 1 are still needed, though -
otherwise the code is invalid:
function multiply(lhs,rhs)
allocate(multiply)
program main
allocate (g%f(2), source = [1.0, 2.0])
* * *
Unfortunately, the original program still fails. New test case; produces with
ifort 12.1:
6.000000 12.00000 18.00000
24.00000 30.00000 36.00000
Fails with gfortran at:
Invalid free() / delete / delete[] / realloc()
at 0x4C28C3E: free (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x401BD0: MAIN__ (test.f90:34)
The "free" issue only occurs for:
fireworks = fireworks + fireworks * dt
It works with
fireworks = fireworks + fireworks
or with
fireworks = fireworks * dt
I am not sure why it fails, but the following looks a bit odd:
struct soop_stars D.1952;
class.8._data = (struct soop_stars *) &D.1952;
...
if (class.8.position.data != 0B)
__builtin_free ((void *) class.8.position.data);
Shouldn't that be: "class.8._data.position.data" (not the "_data")?
module soop_stars_class
implicit none
type soop_stars
real, dimension(:), allocatable :: position,velocity
contains
procedure :: total
procedure :: product
generic :: operator(+) => total
generic :: operator(*) => product
end type
contains
type(soop_stars) function product(lhs,rhs)
class(soop_stars) ,intent(in) :: lhs
real ,intent(in) :: rhs
product%position = lhs%position*rhs
product%velocity = lhs%velocity*rhs
end function
type(soop_stars) function total(lhs,rhs)
class(soop_stars) ,intent(in) :: lhs,rhs
total%position = lhs%position + rhs%position
total%velocity = lhs%velocity + rhs%velocity
end function
end module
program main
use soop_stars_class ,only : soop_stars
implicit none
type(soop_stars) :: fireworks
real :: dt
fireworks%position = [1,2,3]
fireworks%velocity = [4,5,6]
dt = 5
fireworks = fireworks + fireworks*dt
print *, fireworks%position
print *, fireworks%velocity
end program
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/51634] [OOP] ICE with polymorphic operators
2011-12-20 8:57 [Bug fortran/51634] New: [OOP] ICE with polymorphic operators burnus at gcc dot gnu.org
2012-01-02 13:28 ` [Bug fortran/51634] " pault at gcc dot gnu.org
2012-01-13 22:21 ` burnus at gcc dot gnu.org
@ 2012-01-18 23:00 ` pault at gcc dot gnu.org
2012-01-19 8:49 ` burnus at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pault at gcc dot gnu.org @ 2012-01-18 23:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51634
--- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> 2012-01-18 20:52:51 UTC ---
Author: pault
Date: Wed Jan 18 20:52:48 2012
New Revision: 183287
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183287
Log:
2012-01-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/51634
* trans-expr.c (gfc_conv_procedure_call): Deallocate allocatable
components of temporary class arguments.
2012-01-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/51634
* gfortran.dg/typebound_operator_12.f03: New.
* gfortran.dg/typebound_operator_13.f03: New.
Added:
trunk/gcc/testsuite/gfortran.dg/typebound_operator_12.f03
trunk/gcc/testsuite/gfortran.dg/typebound_operator_13.f03
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-expr.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/51634] [OOP] ICE with polymorphic operators
2011-12-20 8:57 [Bug fortran/51634] New: [OOP] ICE with polymorphic operators burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2012-01-18 23:00 ` pault at gcc dot gnu.org
@ 2012-01-19 8:49 ` burnus at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-19 8:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51634
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-19 08:13:13 UTC ---
FIXED on the trunk (4.7).
Thanks for the patch, Paul!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-01-19 8:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-20 8:57 [Bug fortran/51634] New: [OOP] ICE with polymorphic operators burnus at gcc dot gnu.org
2012-01-02 13:28 ` [Bug fortran/51634] " pault at gcc dot gnu.org
2012-01-13 22:21 ` burnus at gcc dot gnu.org
2012-01-18 23:00 ` pault at gcc dot gnu.org
2012-01-19 8:49 ` burnus at gcc dot gnu.org
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).