This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, libfortran] PR 47007, 61847 Locale failures in libgfortran
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 5 Nov 2014 12:54:04 +0100
- Subject: Re: [PATCH, libfortran] PR 47007, 61847 Locale failures in libgfortran
- Authentication-results: sourceware.org; auth=none
- References: <CAO9iq9GHzVk5WCSbj6CwsDWZ=dh3sNhO8qF4pGCmZ8ZpH1XtQg at mail dot gmail dot com> <20141105110722 dot GD5026 at tucnak dot redhat dot com> <CAO9iq9G=aZ8cZmh7Tn1ehHZmecNfwO-cb-xR4FiTjPhvdzwk+Q at mail dot gmail dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Nov 05, 2014 at 01:48:32PM +0200, Janne Blomqvist wrote:
> On Wed, Nov 5, 2014 at 1:07 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> > On Wed, Nov 05, 2014 at 12:48:01PM +0200, Janne Blomqvist wrote:
> >> @@ -3528,6 +3533,11 @@ finalize_transfer (st_parameter_dt *dtp)
> >> if ((dtp->common.flags & IOPARM_DT_HAS_SIZE) != 0)
> >> *dtp->size = dtp->u.p.size_used;
> >>
> >> +#ifdef HAVE_USELOCALE
> >> + if (dtp->u.p.old_locale != (locale_t) 0)
> >> + uselocale (dtp->u.p.old_locale);
> >> +#endif
> >
> > I wonder if you shouldn't clear dtp->u.p.old_locale here too, so
> > that uselocale isn't called again.
>
> Sure. In principle this shouldn't be needed, since IIRC the entire
> dtp->u.p structure is set to 0 when starting an IO operation, but
> OTOH the cost is insignificant.
If finalize transfer is guaranteed to be called exactly once on
a structure on which dtp->u.p.old_locale has been set, then it is ok as is,
though clearing it after such an restoration operation is a good style;
you could e.g. then assert it is NULL when the done with a particular dtp
structure in debugging builds etc.
Jakub