This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

Should axp integers be long int?..was: fmt.c line 95 segfaults


Craig Burley wrote:

> pars_f() parse the FORMAT string.  s_wsfe() is called by a compiled
> Fortran module (f2c or g77) to Start a Write Sequential Formatted
> External (basically, ordinary formatted WRITE or PRINT).  s_wsfe()
> is passed a structure that contains, among other things, a pointer
> to the FORMAT string.  The compiler encodes the data in this structure,
> though of course some of it might come from the program itself at
> run time.
>
> Seems like that pointer is NULL, and if you can find out why, that
> might identify the source of the problem.  In cases like this (64-bit
> machine and all), it might be due to a mismatch between types/sizes
> of the members structure of structure passed to s_wsfe() as seen by
> the compiler and as seen by the run-time library (s_wsfe() itself).
>

 After spending a few
days debugging and reading this code,
I think the problem is
(as Craig Burley speculates) related
to the way variable dimensions are defined
by the compiler for the alpha.

      program bomb
      character*1 Message
      Message = 'X'
        Write(6,1000) Message(1:1)
 1000   Format(A)
      stop
      end

The format specifier "A" is not getting
passed into the "a" structure by 980406.
This does work, however, in 1.0.2.
Compiling first with the 1.0.2
libf2c.a, and then with the 980406 libf2c.a,
the new (egcs-980406) libf2c.a fails where
the old (egcs-1.0.2) libf2c.a works:


**********************************************

Using g77 junk2.f -g -o junk2 -lf2c-980406

Breakpoint 21, s_wsfe (a=0x120106f20) at wsfe.c:60
(gdb) bt
#0  s_wsfe (a=0x120106f20) at wsfe.c:60
#1  0x120001190 in MAIN__ () at junk2.f:4
#2  0x12000145c in main (argc=537947936, argv=0x402c7413) at main.c:128
(gdb) print *a
$8 = {cierr = 25769803776, ciunit = 0, ciend = 4832918048, cifmt = 0x0,
cirec = 4831864504}
(gdb)

**********************************************

Using g77 junk2.f -g -o junk3 -lf2c-1.0.2:

Breakpoint 20, s_wsfe (a=0x120107760) at wsfe.c:60
Current language:  auto; currently c
(gdb) bt
#0  s_wsfe (a=0x120107760) at wsfe.c:60
#1  0x120001168 in MAIN__ () at junk2.f:4
#2  0x12000143c in main (argc=537950048, argv=0x402c7413) at main.c:128
(gdb) print *a
$1 = {cierr = 0, ciunit = 6, ciend = 0, cifmt = 0x120108258 "(A)", cirec
= 0}
(gdb)

**********************************************

The format string, "A", is passed from junk2.f
to the runtime library routine s_wsfe by
way of the compiler.  There is no intervening code.
In one case "a" points to the correct address
and finds "A", and in the other, "a" does not get
a proper address.

I see that integers are defined differently
for the libf2c runtime code by these two
versions.  My questions at this point are:
1.  Should integers be "long int" on the alpha?
2. How are pointers defined?

Here are the (different) typedefs for these two versions,
as created by "configure".

egcs-1.0.2
typedef int /* long int */ flag;
typedef int /* long int */ ftnlen;
typedef int /* long int */ ftnint;

egcs-980406
typedef long int /* long int */ flag;
typedef long int /* long int */ ftnlen;
typedef long int /* long int */ ftnint;

*******************************************




--
Bob Williams, http://bob.usuf2.usuhs.mil/





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