https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77393

--- Comment #8 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
(In reply to Dominique d'Humieres from comment #7)
> > Works for me here!
> 
> Are you sure that you have tested
> 
> print "(f8.0)", huge(1.0)
> print "(f18.0)", huge(1.0_8)
> print "(f20.0)", huge(1.0_10)
> print "(f40.0)", huge(1.0_16)
> end
> 
> ?
$ cat pr77393-b.f90 
print "(f8.0)", huge(1.0)
print "(f18.0)", huge(1.0_8)
print "(f20.0)", huge(1.0_10)
print "(f40.0)", huge(1.0_16)
end
$ gfc pr77393-b.f90 
$ ./a.out 
********
******************
********************
****************************************
$ gfc -v
Using built-in specs.
COLLECT_GCC=gfc
COLLECT_LTO_WRAPPER=/home/jerry/dev/usr/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../trunk/configure --prefix=/home/jerry/dev/usr
--enable-languages=c,c++,fortran --disable-libmudflap --enable-libgomp
--disable-bootstrap
Thread model: posix
gcc version 7.0.0 20160831 (experimental) (GCC) 

Yes, as posted. I suspect, assuming you are on Darwin, that the implementation
of snprintf emits a larger number of bytes. I found on the system here that it
emits the number of characters I used in the routine with the adders.

Can you test by changing the define in write.c line 1349:

#define BUF_STACK_SZ 256

to something absurd like 6000.

Then run this and see how large the strings are:

program testbigf0 ! Can enormous numbers be printed with F0.0 format?
  implicit none
  character(10000) :: str

  write(str,"(f0.0)") -huge(1.0)
  print *, len(trim(str))
  write(str,"(f0.0)") -huge(1.0_8)
  print *, len(trim(str))
  write(str,"(f0.0)") -huge(1.0_10)
  print *, len(trim(str))
  write(str,"(f0.0)") -huge(1.0_16)
  print *, len(trim(str))
end program testbigf0

Also using gdb can you see where the segfault occurs with the pr77393-b.f90 
version above.

Reply via email to