"gfc_code2string(): Bad code" error for gfortran-4.3.2 on Darwin PPC
Chris Talley
cst@cfdrc.com
Thu Sep 4 21:24:00 GMT 2008
Hi Tobias,
I followed your instruction but ran into a problem. The "gfortran-432
-ffree-form -S -v dummy_mod.F" command returned:
/usr/local/gcc432/libexec/gcc/powerpc-apple-darwin8.11.0/4.3.2/
f951 /var/tmp//ccxfGHJm.f -fPIC -quiet -dumpbase dummy_mod.F -mmacosx-
version-min=10.4 -auxbase dummy_mod -version -ffree-form -o
dummy_mod.s -fpreprocessed -fintrinsic-modules-path /usr/local/gcc432/
lib/gcc/powerpc-apple-darwin8.11.0/4.3.2/finclude
I then ran "gdb --args /usr/local/gcc432/libexec/gcc/powerpc-apple-
darwin8.11.0/4.3.2/f951 /var/tmp//ccxfGHJm.f -fPIC -quiet -dumpbase
dummy_mod.F -mmacosx-version-min=10.4 -auxbase dummy_mod -version -
ffree-form -o dummy_mod.s -fpreprocessed -fintrinsic-modules-path /
usr/local/gcc432/lib/gcc/powerpc-apple-darwin8.11.0/4.3.2/finclude"
After setting the breakpoint and typing 'run', I get the following
output:
>Starting program: /usr/local/gcc432/libexec/gcc/powerpc-apple-
darwin8.11.0/4.3.2/f951 >/var/tmp//ccTmieJp.f -fPIC -quiet -dumpbase
dummy_mod.F -mmacosx-version-min=10.4 -auxbase dummy_mod ->version -
ffree-form -o dummy_mod.s -fpreprocessed -fintrinsic-modules-path >/
usr/local/gcc432/lib/gcc/powerpc-apple-darwin8.11.0/4.3.2/finclude
>Reading symbols for shared libraries .++ done
>GNU F95 (GCC) version 4.3.2 (powerpc-apple-darwin8.11.0)
> compiled by GNU C version 4.3.2, GMP version 4.2.2, MPFR
version 2.3.1.
>GGC heuristics: --param ggc-min-expand=100 --param ggc-min-
heapsize=131072
>Error: Can't open file '/var/tmp//ccTmieJp.f'
><built-in>:0: fatal error: can't open input file: /var/tmp//ccTmieJp.f
>compilation terminated.
>
>Program exited with code 01.
After that I played around with the logical line in dummy_mod.F, and
found that kind type of the logical must be the same as the kind type
of the constant being assigned as follows:
logical (kind=1) :: MEMCHEKDONE = .false._1
or
logical :: MEMCHEKDONE = .false.
Both of these lines compile with 4.3.2, whereas the original
logical (kind=1) :: MEMCHEKDONE = .false.
compiled with 4.2.4. Also, remember that the error only shows up with
the mismatched logical kinds in a module being used by a module
containing the 'CNT = count(A == 1)' line.
Could this be a case of a 1-byte logical being initialized by a 4-
byte logical, resulting in memory corruption that only shows up when
the 'CNT = count(A == 1)' line is present? Shouldn't gfortran auto
convert the 4-byte logical in the 'dummy_mod.F' as it apparently did
in 4.2.4?
Thanks,
Chris Talley
Senior Aerospace Engineer
CFD Research Corporation
215 Wynn Drive
Huntsville, AL 35805
256-726-4835
cst at cfdrc dot com
> Hi Chris,
>
> Chris Talley wrote:
> > By changing the line in dummy_mod.F from
> > > logical (kind=1) :: MEMCHEKDONE = .false.
> > to
> > > logical :: MEMCHEKDONE = .false.
> > the code compiles without an error.
> >
> > What is the difference between a 'logical (kind=1)' and a 'logical'?
>
> "logical" has the same size as an "integer", which is [usually] 4
> bytes.
> "logical(kind=1)" has the same storage size as "integer(kind=1)",
> namely
> 1 byte.
>
> If I recall correctly, "logical(kind=4)" is a tiny bit faster while
> "logical(kind=1)" uses less memory (a quarter). In most programs,
> neither the storage size for logical variables is negligible.
>
> (Unless your variable "MEMCHEKDONE" is in a COMMON block, changing the
> size should cause no algorithmic problems.)
>
> * * *
>
> Coming back to your problem: Similar to Daniel, I cannot reproduce it
> on x86-64-linux with either gfortran 4.3 nor with today's 4.4.0.
>
> The "gfc_code2string()" function is used to read/write data from/to
> module files. At a glance I cannot see what could go wrong there.
>
> Can you run gfortran in a debugger and provide thus more information.
> Steps:
> 1. Run: "gfortran-432 -ffree-form -S -v dummy_mod.F"
> and find in the output the line containing
> .../4.3.2/f951 ...
> 2. Run: gdb --args .../4.3.2/f951 ...
> 3. Set a break point in "gdb" at gfc_code2string
> 4. Type "run"
>
> When you are in "gfc_code2string", can you print the value of "m-
> >string"
> and of "code"? It would be interesting to know for which values it
> fails.
>
> Tobias
More information about the Fortran
mailing list