diff mbox series

[committed] PR83811 fortran 'e' format broken for single digit exponents

Message ID 4f4c9fe9-f1b0-c707-71dc-4218d7b9ec5f@charter.net
State New
Headers show
Series [committed] PR83811 fortran 'e' format broken for single digit exponents | expand

Commit Message

Jerry DeLisle Jan. 14, 2018, 5:42 p.m. UTC
Hello all,

I committed the following as trivial.

Regression tested on x86_64-pc-linux-gnu.

This is a regression on 7 so I will backport.

Regards,

Jerry

2018-01-18  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/83811
	* write.c (select_buffer): Adjust buffer size up by 1.

      result = xmalloc (*size);

New test case:

! { dg-do run }
! PR83811 fortran 'e' format broken for single digit exponents
program test
  character(25) :: s
  write(s, '(1pe5.0e1)') 1.e-4
  if (s.ne."1.E-4") call abort
  write(s, '(e5.1e1)') 1.e12
  if (s.ne."*****") call abort
end

Comments

Jerry DeLisle Jan. 14, 2018, 9:49 p.m. UTC | #1
On 01/14/2018 09:42 AM, Jerry DeLisle wrote:
> Hello all,
> 
> I committed the following as trivial.
> 
> Regression tested on x86_64-pc-linux-gnu.
> 
> This is a regression on 7 so I will backport.
> 
> Regards,
> 
> Jerry
> 
> 2018-01-18  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
> 
> 	PR libgfortran/83811
> 	* write.c (select_buffer): Adjust buffer size up by 1.
> 

Committed to gcc7 after regression testing and I fixed the dates I had in the
ChangeLogs.

Cheers,

Jerry
diff mbox series

Patch

diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 8021a1e9c4b..28ea852867b 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -1519,8 +1519,9 @@  select_buffer (st_parameter_dt *dtp, const fnode *f, int
precision,
 {
   char *result;

-  /* The buffer needs at least one more byte to allow room for normalizing.  */
-  *size = size_from_kind (dtp, f, kind) + precision + 1;
+  /* The buffer needs at least one more byte to allow room for
+     normalizing and 1 to hold null terminator.  */
+  *size = size_from_kind (dtp, f, kind) + precision + 1 + 1;

   if (*size > BUF_STACK_SZ)