This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/33386] New: Fortran SELECT statement miscompiles


In my application a wrong CASE is occationally selected in a SELECT statement.
I've not been able to reduce the code to do the wrong jump. However, the
following simple code run through valgrind gives uninitialized variable
warnings, which i think might be the source of the problem:

   REAL :: x = 0

   SELECT CASE( getstring() )
     x = 1
     x = 2


  FUNCTION getstring() RESULT(s)
    CHARACTER(LEN=1) :: s
    s = 'c'
  END FUNCTION getstring


Driving: gfortran -v -O0 -g -o a a.f90 -lgfortranbegin -lgfortran -lm
Using built-in specs.
Target: i386-pc-linux-gnu
Configured with: /home/fx/gfortran_nightbuild/trunk/configure
--enable-languages=c,fortran --build=i386-pc-linux-gnu
--enable-checking=release --with-gmp=/home/fx/gfortran_nightbuild/software
Thread model: posix
gcc version 4.3.0 20070910 (experimental) [trunk revision 128320] (GCC)
COLLECT_GCC_OPTIONS='-v' '-O0' '-g' '-o' 'a' '-shared-libgcc' '-mtune=i386'
 /home/wrk/jpr/irun/bin/../libexec/gcc/i386-pc-linux-gnu/4.3.0/f951 a.f90
-quiet -dumpbase a.f90 -mtune=i386 -auxbase a -g -O0 -version
/home/wrk/jpr/irun/bin/../lib/gcc/i386-pc-linux-gnu/4.3.0/finclude -o
GNU F95 (GCC) version 4.3.0 20070910 (experimental) [trunk revision 128320]
        compiled by GNU C version 4.3.0 20070910 (experimental) [trunk revision
128320], GMP version 4.2.1, MPFR version 2.2.1.
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64211
COLLECT_GCC_OPTIONS='-v' '-O0' '-g' '-o' 'a' '-shared-libgcc' '-mtune=i386'
 as -V -Qy -o /tmp/ccGk0ias.o /tmp/ccouIARh.s
GNU assembler version (i386-redhat-linux) using BFD version 20040927
COLLECT_GCC_OPTIONS='-v' '-O0' '-g' '-o' 'a' '-shared-libgcc' '-mtune=i386'
--eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ -o a
/usr/lib/crt1.o /usr/lib/crti.o
/tmp/ccGk0ias.o -lgfortranbegin -lgfortran -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc

valgrind ./a
==4319== Memcheck, a memory error detector.
==4319== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==4319== Using LibVEX rev 1575, a library for dynamic binary translation.
==4319== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
==4319== Using valgrind-3.1.1, a dynamic binary instrumentation framework.
==4319== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==4319== For more details, rerun with: -v
==4319== Conditional jump or move depends on uninitialised value(s)
==4319==    at 0x80485CE: MAIN__ (a.f90:4)
==4319==    by 0x8048690: main (fmain.c:21)
==4319== Conditional jump or move depends on uninitialised value(s)
==4319==    at 0x80485D7: MAIN__ (a.f90:4)
==4319==    by 0x8048690: main (fmain.c:21)
==4319== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 17 from 1)
==4319== malloc/free: in use at exit: 0 bytes in 0 blocks.
==4319== malloc/free: 11 allocs, 11 frees, 25,425 bytes allocated.
==4319== For counts of detected errors, rerun with: -v
==4319== All heap blocks were freed -- no leaks are possible.

Adding a default case gets rid of the problems, also for my real application

Regards, Juha

           Summary: Fortran  SELECT statement miscompiles
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jpr at csc dot fi
  GCC host triplet: i386 linux

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]