In the following program, the function should only be called once. However, with GCC 4.5 the function is called twice (see dump).
MAIN__ () { struct fgsl_interp interp; { struct fgsl_interp D.1347; static integer(kind=4) C.1345 = 1; D.1347 = fgsl_interp_alloc (&C.1345); interp = fgsl_interp_alloc (&C.1345); } } module m use iso_c_binding type :: fgsl_interp type(c_ptr) :: gsl_interp end type fgsl_interp contains function fgsl_interp_alloc(size) integer, intent(in) :: size type(fgsl_interp) :: fgsl_interp_alloc logical :: double = .false. if (double) call abort() double = .true. fgsl_interp_alloc%gsl_interp = c_null_ptr end function fgsl_interp_alloc end module m use m type(fgsl_interp) :: interp interp = fgsl_interp_alloc(1) end -- Summary: [4.5 Regression] Functions are called twice Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org OtherBugsDependingO 41293 nThis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41297