[Bug fortran/59484] New: execute_command_line doesn't play with environment variables

demarchie at web dot de gcc-bugzilla@gcc.gnu.org
Thu Dec 12 13:56:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59484

            Bug ID: 59484
           Summary: execute_command_line doesn't play with environment
                    variables
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: demarchie at web dot de

Please compile:

program test
  implicit none

  character(len=11) :: cmdmsg,str
  integer :: exitstat,cmdstat,status,length
  logical :: wait
  wait   = .true.
  cmdmsg = "ok"

  call execute_command_line("export newvar='some text'")
  print *,"result 1:", exitstat, cmdstat, cmdmsg
  call get_environment_variable("newvar",str,length,status)
  print *,"1:     ",str,length,status
  print *,"expected:","some text",9,0; print *,""

  call execute_command_line("read -n5 myvar", wait, exitstat, cmdstat, cmdmsg)
  print *,"result 2:", exitstat, cmdstat, cmdmsg
  call get_environment_variable("myvar",str,length,status)
  print *,"2:",str,length,status

  call execute_command_line("myvar='text'", wait, exitstat, cmdstat, cmdmsg)
  print *,""; print *,"result 3:", exitstat, cmdstat, cmdmsg
  call get_environment_variable("myvar",str,length,status)
  print *,"3:",str,length,status
  print *,"expected:","text",4,0

end program test


Now try in bash:
export myvar="not good"
./a.out
(type "great")


Output is (gfortran-4.8.2):

 execute 1: -1073743632 -1073742765 ok       
 get 1:                       0           1
 expected:some text           9           0

great execute 2:           0           0 ok       
 get 2:not good            8           0
 expected:great            5           0

 execute 3:           0           0 ok       
 get 3:not good            8           0
 expected:text             4           0

*****

/sw/bin/gfortran -v -save-temps test.f90

Angesteuert: /sw/bin/gfortran -mmacosx-version-min=10.4 -v -save-temps test.f90
-l gfortran -shared-libgcc
Es werden eingebaute Spezifikationen verwendet.
COLLECT_GCC=/sw/bin/gfortran
COLLECT_LTO_WRAPPER=/sw/lib/gcc4.8/libexec/gcc/powerpc-apple-darwin8.11.0/4.8.2/lto-wrapper
Ziel: powerpc-apple-darwin8.11.0
Konfiguriert mit: ../gcc-4.8.2/configure --prefix=/sw AS=odas
AS_FOR_TARGET=odas NM_FOR_TARGET=odnm LD_FOR_TARGET=odld AR_FOR_TARGET=odar
LIPO_FOR_TARGET=odlipo OBJDUMP_FOR_TARGET=odobjdump RANLIB_FOR_TARGET=odranlib
STRIP_FOR_TARGET=odstrip --prefix=/sw/lib/gcc4.8 --mandir=/sw/share/man
--infodir=/sw/lib/gcc4.8/info
--enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw
--with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw
--with-system-zlib --enable-checking=release --x-includes=/usr/X11R6/include
--x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.8 --with-dwarf2
--disable-libjava-multilib --disable-libquadmath
Thread-Modell: posix
gcc-Version 4.8.2 (GCC) 
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.4' '-v' '-save-temps'
'-shared-libgcc'
 /sw/lib/gcc4.8/libexec/gcc/powerpc-apple-darwin8.11.0/4.8.2/f951 test.f90
-fPIC -quiet -dumpbase test.f90 -mmacosx-version-min=10.4 -auxbase test
-version -fintrinsic-modules-path
/sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/4.8.2/finclude -o test.s
GNU Fortran (GCC) Version 4.8.2 (powerpc-apple-darwin8.11.0)
        kompiliert von GNU-C-Version 4.8.2, GMP-Version 5.1.3, MPFR-Version
3.1.2, MPC-Version 1.0.1.
GGC-Heuristik: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran (GCC) Version 4.8.2 (powerpc-apple-darwin8.11.0)
        kompiliert von GNU-C-Version 4.8.2, GMP-Version 5.1.3, MPFR-Version
3.1.2, MPC-Version 1.0.1.
GGC-Heuristik: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.4' '-v' '-save-temps'
'-shared-libgcc'
 as -arch ppc -o test.o test.s
Lesen der Spezifikationen von
/sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/4.8.2/../../../libgfortran.spec
Spezifikation wird von lib nach liborig umbenannt
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.4' '-v' '-save-temps'
'-shared-libgcc'
COMPILER_PATH=/sw/lib/gcc4.8/libexec/gcc/powerpc-apple-darwin8.11.0/4.8.2/:/sw/lib/gcc4.8/libexec/gcc/powerpc-apple-darwin8.11.0/4.8.2/:/sw/lib/gcc4.8/libexec/gcc/powerpc-apple-darwin8.11.0/:/sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/4.8.2/:/sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/
LIBRARY_PATH=/sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/4.8.2/:/sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/4.8.2/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.4' '-v' '-save-temps'
'-shared-libgcc'
 /sw/lib/gcc4.8/libexec/gcc/powerpc-apple-darwin8.11.0/4.8.2/collect2 -dynamic
-arch ppc -macosx_version_min 10.4 -multiply_defined suppress
-weak_reference_mismatches non-weak -o a.out -lcrt1.o
/sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/4.8.2/crt3.o
-L/sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/4.8.2
-L/sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/4.8.2/../../.. test.o
-lgfortran -lgcc_s.10.4 -lgcc_ext.10.4 -lgcc -lm -lgcc_s.10.4 -lgcc_ext.10.4
-lgcc -lSystemStubs -lSystem -v
collect2-Version 4.8.2
/opt/local/bin/ld -dynamic -arch ppc -macosx_version_min 10.4 -multiply_defined
suppress -weak_reference_mismatches non-weak -o a.out -lcrt1.o
/sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/4.8.2/crt3.o
-L/sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/4.8.2
-L/sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/4.8.2/../../.. test.o
-lgfortran -lgcc_s.10.4 -lgcc_ext.10.4 -lgcc -lm -lgcc_s.10.4 -lgcc_ext.10.4
-lgcc -lSystemStubs -lSystem -v
@(#)PROGRAM:ld  PROJECT:ld64-97.17
Library search paths:
        /sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/4.8.2
        /sw/lib/gcc4.8/lib
        /usr/lib
        /usr/local/lib
Framework search paths:
        /Library/Frameworks/
        /System/Library/Frameworks/
ld: warning: object file compiled with -mlong-branch which is no longer needed.
To remove this warning, recompile without -mlong-branch: /usr/lib/crt1.o
ld: warning: object file compiled with -mlong-branch which is no longer needed.
To remove this warning, recompile without -mlong-branch:
/sw/lib/gcc4.8/lib/gcc/powerpc-apple-darwin8.11.0/4.8.2/crt3.o



More information about the Gcc-bugs mailing list