https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96486
--- Comment #28 from Susi Lehtola ---
Harald, Andreas, thanks for clarifying: yes, "crash" == Fortran runtime error.
The program should run just fine, since the return array has the proper size
given by get_environment_variable. Instead, it ends
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96486
--- Comment #23 from Susi Lehtola ---
The expected result is that the program does not crash, since a zero-size
character array is enough to fit an empty string.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96486
Susi Lehtola changed:
What|Removed |Added
Summary|get_environment_variable|get_environment_variable
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96486
--- Comment #21 from Susi Lehtola ---
to repeat: libgfortran crashes when you try to read an environment variable
that is an empty string, in the case you have preallocated an array that is the
proper size i.e. zero characters.
I don't get any m
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96486
--- Comment #19 from Susi Lehtola ---
(In reply to Steve Kargl from comment #17)
> On Thu, Aug 06, 2020 at 08:33:12PM +0000, jussilehtola at fedoraproject dot
> org wrote:
> > https://gcc.gnu.org/bugzilla/show_bug.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96486
--- Comment #16 from Susi Lehtola ---
Yes, then I installed missing libgfortran debuginfos and the backtrace
shortened to
#0 0x401267 in zerolen_value
at /tmp/readvar2.f90:17
#1 0x4012c4 in main
at /tmp/readvar2.f90:22
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96486
--- Comment #13 from Susi Lehtola ---
The gdb output is the same
(gdb) r
Starting program: /tmp/a.out
Fortran runtime error: Zero-length string passed as value to
get_environment_variable.
Error termination. Backtrace:
#0 0x401267 in zerolen_
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96486
--- Comment #10 from Susi Lehtola ---
Compiled with -g, rerun gives
$ ./a.out
Fortran runtime error: Zero-length string passed as value to
get_environment_variable.
Error termination. Backtrace:
#0 0x401267 in zerolen_value
at /tmp/re
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96486
--- Comment #8 from Susi Lehtola ---
(In reply to kargl from comment #5)
> What gfortran version and operating system? I get
>
> % gfcx -o z b.f90 && ./z
> STOP System variable unassigned
> % gfcx -o z -g b.f90 && ./z
> STOP System variable una
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96486
--- Comment #4 from Susi Lehtola ---
$ export HOSTNAME=foo
$ ./a.out
$
$ export HOSTNAME=
$ ./a.out
Fortran runtime error: Zero-length string passed as value to
get_environment_variable.
Error termination. Backtrace:
#0 0x7f25c93aadf1 in ???
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96486
--- Comment #3 from Susi Lehtola ---
program zerolen_value
implicit none
character(len=*), parameter :: name='HOSTNAME'
character(len=:), allocatable :: value
integer :: l, err
call get_environment_variable(name,length=l,status=err)
i
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: jussilehtola at fedoraproject dot org
Target Milestone: ---
get_environment_variable checks for zero-length value strings before it checks
the length of the result string.
In the case of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60871
Susi Lehtola changed:
What|Removed |Added
CC||jussilehtola@fedoraproject.
13 matches
Mail list logo