http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48960
--- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2012-12-25 04:24:33 UTC --- Proposed patch being tested;: Index: open.c =================================================================== --- open.c (revision 194678) +++ open.c (working copy) @@ -844,10 +844,7 @@ st_open (st_parameter_open *opp) if ((opp->common.flags & IOPARM_LIBRETURN_MASK) == IOPARM_LIBRETURN_OK) { if ((opp->common.flags & IOPARM_OPEN_HAS_NEWUNIT)) - { - *opp->newunit = get_unique_unit_number(opp); - opp->common.unit = *opp->newunit; - } + opp->common.unit = get_unique_unit_number(opp); u = find_or_create_unit (opp->common.unit); if (u->s == NULL) @@ -859,6 +856,9 @@ st_open (st_parameter_open *opp) else already_open (opp, u, &flags); } - + + if ((opp->common.flags & IOPARM_LIBRETURN_MASK) == IOPARM_LIBRETURN_OK) + *opp->newunit = opp->common.unit; + library_end (); }