This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/42831] Unnecessary array temporary produced
- From: "dfranke at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 May 2010 22:13:05 -0000
- Subject: [Bug fortran/42831] Unnecessary array temporary produced
- References: <bug-42831-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from dfranke at gcc dot gnu dot org 2010-05-09 22:13 -------
Somewhat reduced testcase below.
Note that the temporary depends on the POINTER attribute of 'table'. If POINTER
and corresponding ALLOCATE are removed, there is no more temporary array. Also,
if CENTIMETER is changed to simple REAL, but 'table' is still a POINTER, the
temporary is omitted.
module UnitValue_Module
type :: UnitValue
real :: Value = 1.0
end type
interface operator(*)
module procedure ProductReal_LV
end interface operator(*)
interface assignment(=)
module procedure Assign_LV_Real
end interface assignment(=)
contains
elemental function ProductReal_LV(Multiplier, Multiplicand) result(P_R_LV)
real, intent(in) :: Multiplier
type(UnitValue), intent(in) :: Multiplicand
type(UnitValue) :: P_R_LV
P_R_LV%Value = Multiplier * Multiplicand%Value
end function ProductReal_LV
elemental subroutine Assign_LV_Real(LeftHandSide, RightHandSide)
real, intent(inout) :: LeftHandSide
type(UnitValue), intent(in) :: RightHandSide
LeftHandSide = RightHandSide%Value
end subroutine Assign_LV_Real
end module UnitValue_Module
program TestProgram
use UnitValue_Module
type :: TableForm
real, dimension(:,:), allocatable :: RealData
end type TableForm
REAL :: CENTIMETER
type(TableForm), pointer :: Table
allocate(Table)
allocate(Table%RealData(10,5))
CENTIMETER = 42
Table%RealData = 1
Table%RealData(:,1) = Table%RealData(:,1) * CENTIMETER
end program TestProgram
--
dfranke at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dfranke at gcc dot gnu dot
| |org
OtherBugsDependingO| |36854
nThis| |
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-05-09 22:13:05
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42831