From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21836 invoked by alias); 21 Jul 2014 19:50:41 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 21749 invoked by uid 48); 21 Jul 2014 19:50:36 -0000 From: "dominiq at lps dot ens.fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/61847] bug in gfortran runtime: digits cut off when reading floating point number Date: Mon, 21 Jul 2014 19:50:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.8.3 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dominiq at lps dot ens.fr X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: short_desc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-07/txt/msg01476.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61847 Dominique d'Humieres changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|bug in gfortran runtime on |bug in gfortran runtime: |OSX: digits cut off when |digits cut off when reading |reading floating point |floating point number |number | --- Comment #10 from Dominique d'Humieres --- I can reproduce this PR on a linux box with gcc version 4.6.3 20120306 (Red Hat 4.6.3-2), so the bug is not darwin specific. I have noticed that the file generated by running the test is 1.2345 and does not change if I put the line setlocale(LC_ALL, "de_DE.UTF-8"); before the line f = fopen("bug.dat", "w"); Now if I change the content of bug.dat to 1,2345 suppress the file generation in bug.c and use open(unit=1,file='bug.dat', decimal='comma') in bugf.f90, running the executable does not give any output (success). So apparently strtod uses the locale to read 1.2345, giving 1.0 as a result for "de_DE.UTF-8" (or "fr_FR.UTF-8"), using "en_US.ISO8859-1" gives 1.2345. The only solution I see is to save the current locale, set it to "C" before using strtod, and restore it upon completion.