gfortran scan() intrinsic yields incorrect results, see code snippet below klaus@platon:~/src/F90/bugs> cat scanbug.f90 program scanbug character(len=10) :: numset='0123456789' print *, scan('0123456789', '9') print *, scan(numset, '9') end program scanbug klaus@platon:~/src/F90/bugs> gfortran scanbug.f90 -o scanbug klaus@platon:~/src/F90/bugs> ./scanbug 10 0 klaus@platon:~/src/F90/bugs> gcc --version gcc (GCC) 4.1.0 20050930 (experimental) Copyright (C) 2005 Free Software Foundation, Inc. Dies ist freie Software; die Kopierbedingungen stehen in den Quellen. Es gibt KEINE Garantie; auch nicht für VERKAUFBARKEIT oder FÜR SPEZIELLE ZWECKE.
I think this is a dup of bug 24787 but I don't know for sure as I don't have a build of gfortran after the patch was applied.
kargl[203] cat > a.f90 program scanbug character(len=10) :: numset='0123456789' print *, scan('0123456789', '9') print *, scan(numset, '9') end program scanbug kargl[204] gfc41 -o z a.f90 kargl[205] ./z 10 10 The bug as fixed on 2005-11-12. Please update to newer gfortran