------- Additional Comments From fxcoudert at gcc dot gnu dot org 2005-09-11 21:27 ------- This is a front-end bug. We generate wrong code for all the ioparm members that are passed by reference (the pointers are cast, instead of creating temporaries). All cases handled by set_parameter_ref (in trans-io.c) are handled incorrectly when given a kind different that the GFC_INTEGER_4. Exhaustive list (hopefully) is: iostat, exist, opened, number, named, recl, nextrec, size and iolength. Two examples:
$ cat a.f90 logical*8 ex inquire (file="foo",exist=ex) end $ gfortran -fdump-tree-original a.f90 $ cat a.f90.t02.original MAIN__ () { logical8 ex; _gfortran_filename = "a.f90"; _gfortran_line = 2; _gfortran_ioparm.file = "foo"; _gfortran_ioparm.file_len = 3; _gfortran_ioparm.exist = (int4 *) &ex; _gfortran_st_inquire (); } $ cat b.f90 integer*8 i write(*,"()",iostat=i) end $ gfortran -fdump-tree-original b.f90 $ cat b.f90.t02.original MAIN__ () { int8 i; _gfortran_filename = "b.f90"; _gfortran_line = 2; _gfortran_ioparm.unit = 6; _gfortran_ioparm.format = "()"; _gfortran_ioparm.format_len = 2; _gfortran_ioparm.iostat = (int4 *) &i; _gfortran_st_write (); _gfortran_st_write_done (); } My guess is that in both cases, we should create a temporary before the call, set the ioparm member to that temporary, make the library call and then get the value from the temporary back to the real variable. Unfortunately, I have no idea how to do that (i'm not much of a front-end guy). -- What |Removed |Added ---------------------------------------------------------------------------- Component|libfortran |fortran Keywords| |wrong-code Last reconfirmed|2005-05-19 16:51:29 |2005-09-11 21:27:46 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21647