public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, committed] PR83811 fortran 'e' format broken for single digit exponents
@ 2018-01-14 17:42 Jerry DeLisle
  2018-01-14 21:49 ` Jerry DeLisle
  0 siblings, 1 reply; 2+ messages in thread
From: Jerry DeLisle @ 2018-01-14 17:42 UTC (permalink / raw)
  To: gfortran; +Cc: gcc patches

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.

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)
      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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch, committed] PR83811 fortran 'e' format broken for single digit exponents
  2018-01-14 17:42 [patch, committed] PR83811 fortran 'e' format broken for single digit exponents Jerry DeLisle
@ 2018-01-14 21:49 ` Jerry DeLisle
  0 siblings, 0 replies; 2+ messages in thread
From: Jerry DeLisle @ 2018-01-14 21:49 UTC (permalink / raw)
  To: gfortran; +Cc: gcc patches

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-14 21:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-14 17:42 [patch, committed] PR83811 fortran 'e' format broken for single digit exponents Jerry DeLisle
2018-01-14 21:49 ` Jerry DeLisle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).