* Should axp integers be long int?..was: fmt.c line 95 segfaults
[not found] <199803301732.MAA01231@melange.gnu.org>
@ 1998-04-10 19:56 ` Robert Williams
1998-04-10 20:20 ` Michal Jaegermann
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Robert Williams @ 1998-04-10 19:56 UTC (permalink / raw)
To: Craig Burley; +Cc: egcs-bugs, axp-list
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/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Should axp integers be long int?..was: fmt.c line 95 segfaults
1998-04-10 19:56 ` Robert Williams
@ 1998-04-10 20:20 ` Michal Jaegermann
1998-04-11 10:52 ` Toon Moene
1998-04-14 11:50 ` Loic Prylli
2 siblings, 0 replies; 5+ messages in thread
From: Michal Jaegermann @ 1998-04-10 20:20 UTC (permalink / raw)
To: axp-list; +Cc: burley
>
> 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?
They should not. Even only if tons of Fortran code assume that
INTEGER and INTEGER*4 are the same thing (is this a Standard
requirement? I do not have relevant documents on hand.)
f2c had the same problem, which likely stems from a need to
acommodate MS-DOS machines with 16-bit ints, and it was a big
pain in the ass and a performance drag.
> 2. How are pointers defined?
???? Why this matters? Adresses on Alpha happen to be 8-bytes wide.
>
> 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;
Bummer! Not again! I actually filed a bug report, accepted, against
some snapshots between 1.0.1 and 1.0.2 because 'configure' was broken
and this 'long int' stuff showed once more and immediately created a
havoc in a library. My temporary workaround was to add Makefile entries
which were editing automatically bad typedefs before they were used.
For reasons unclear it looks like that releases of egcs get it right
and snapshots are breaking configure script. Mind you, snapshots are
not guaranteed to work at all and if play with they then you are
on your own and you are supposed to report bugs fast (with possible fixes).
Still I wonder why this bug shows up again, and again, and ...
Michal
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Should axp integers be long int?..was: fmt.c line 95 segfaults
1998-04-10 19:56 ` Robert Williams
1998-04-10 20:20 ` Michal Jaegermann
@ 1998-04-11 10:52 ` Toon Moene
1998-04-14 11:50 ` Loic Prylli
2 siblings, 0 replies; 5+ messages in thread
From: Toon Moene @ 1998-04-11 10:52 UTC (permalink / raw)
To: axp-list; +Cc: egcs-bugs
Bob,
You wrote:
QUOTE
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;
UNQUOTE
Indeed, this is a bug. The 1.0.2 system works correctly (I just
checked). I also checked that a freshly cvs'd copy of the main
trunk has the wrong definitions. Could someone please take the blame
for this change :-)
Cheers,
Toon.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Should axp integers be long int?..was: fmt.c line 95 segfaults
1998-04-10 19:56 ` Robert Williams
1998-04-10 20:20 ` Michal Jaegermann
1998-04-11 10:52 ` Toon Moene
@ 1998-04-14 11:50 ` Loic Prylli
2 siblings, 0 replies; 5+ messages in thread
From: Loic Prylli @ 1998-04-14 11:50 UTC (permalink / raw)
To: axp-list
Robert Williams writes:
> 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;
>
On my computer when building egcs-980406 this typedef are only ints, I
wonder what made the difference (I built as described in my previous
mail).
egcs-980406% grep -A5 -B5 "typedef.*ftnlen" obj/libraries/libf2c/f2c.h
#ifdef f2c_i2
#error "f2c_i2 will not work with g77!!!!"
/* for -i2 */
typedef short flag;
typedef short ftnlen;
typedef short ftnint;
#else
typedef int /* long int */ flag;
typedef int /* long int */ ftnlen;
typedef int /* long int */ ftnint;
#endif
Regards,
Loic
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Should axp integers be long int?..was: fmt.c line 95 segfaults
@ 1998-04-17 0:17 Craig Burley
0 siblings, 0 replies; 5+ messages in thread
From: Craig Burley @ 1998-04-17 0:17 UTC (permalink / raw)
To: axp-list
[Apologies if this has already been addressed...apparently I was
removed from the list, probably due to a bounce happening,
sometime in the past two weeks.]
>> 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?
>
>They should not. Even only if tons of Fortran code assume that
>INTEGER and INTEGER*4 are the same thing (is this a Standard
>requirement? I do not have relevant documents on hand.)
No, it is not a standard requirement. I think the default being
INTEGER*4 simply caters to people's expectations based on 32-bit
systems, their existing unformatted I/O files, and so on; no
particular reason why a Fortran compiler can't default INTEGER and
REAL to 64 bits, as long as DOUBLE PRECISION is thus 128 bits
(though whether you actually *get* additional precision is
not something the standard says much about! ;-).
>> 2. How are pointers defined?
>
>???? Why this matters? Adresses on Alpha happen to be 8-bytes wide.
g77 has some relevant write-ups on its attempts to cater to
people trying to write 32/64-bit portable code using extensions
to Fortran like %LOC (aka LOC()). E.g. INTEGER(KIND=7), IIRC.
So you can currently ask g77 to make an INTEGER variable wide
enough to hold a %LOC-style pointer, FWIW. Matters for some
things, like calling SIGNAL, for example.
>Still I wonder why this bug shows up again, and again, and ...
Yeah, so do I. I'm not fully up on this stuff (my Alpha is still
sitting around, taken apart, awaiting my spending more time looking
for reasons the SCSI subsystem doesn't work, etc., while I work
on g77 0.5.23.) If/when my Alpha is back up and happy building
gcc/egcs for me, I'll look into these things, but I suspect someone
else (in the egcs community) will beat me to this and other bugs.
tq vm, (burley)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1998-04-17 0:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-04-17 0:17 Should axp integers be long int?..was: fmt.c line 95 segfaults Craig Burley
[not found] <199803301732.MAA01231@melange.gnu.org>
1998-04-10 19:56 ` Robert Williams
1998-04-10 20:20 ` Michal Jaegermann
1998-04-11 10:52 ` Toon Moene
1998-04-14 11:50 ` Loic Prylli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox