http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49509
Summary: cannot promote types for arguments passed by value Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: stev...@alum.mit.edu Compile the following test program gfortran, which is a toy example of iso_c_binding that calls malloc(3). program bug use, intrinsic :: iso_c_binding implicit none interface type(C_PTR) function malloc(n) bind(C, name='malloc') import integer(C_SIZE_T), value :: n end function malloc end interface integer, parameter :: n = 3 integer(C_SIZE_T) sz type(C_PTR) p p = malloc(n) ! compiler error, cannot promote argument passed by value sz = n ! ... whereas assignment succeeds p = malloc(sz) end program bug I obtain the following error: promote.f03:15.13: p = malloc(n) ! compiler error, cannot promote argument type 1 Error: Type mismatch in argument 'n' at (1); passed INTEGER(4) to INTEGER(8) (Similarly with older versions of gcc.) Note that "n" is passed by value, so my understanding is that this should act much like the assignment sz = n (which succeeds): gfortran should automatically promote n to a size_t, like any other assignment of a narrower type to a wider type. Please consider applying the same type-promotion rules that are used for assignments to passing arguments by value. (I don't have the Fortran 2003 standard handy, but it is hard to believe that the two situations should be treated differently.)