cast to pointer from integer of different size
Janne Blomqvist
Janne.Blomqvist@tkk.fi
Sun Sep 10 21:38:00 GMT 2006
Steve Kargl wrote:
> On Sun, Sep 10, 2006 at 09:29:51PM +0200, Thomas Koenig wrote:
>> On Sun, Sep 10, 2006 at 11:57:44AM -0700, Steve Kargl wrote:
>>
>>> Why? The code is casting to an int. int and INTEGER are
>>> corresponding types. This is what g77's signal is documented
>>> to return.
>> >From the g77 info file:
>>
>> # CALL Signal(NUMBER, HANDLER, STATUS)
>> #
>> # NUMBER: `INTEGER'; scalar; INTENT(IN).
>> #
>> # HANDLER: Signal handler (`INTEGER FUNCTION' or `SUBROUTINE') or
>> # dummy/global `INTEGER(KIND=1)' scalar.
>> #
>> # STATUS: `INTEGER(KIND=7)'; OPTIONAL; scalar; INTENT(OUT).
>>
>> and
>>
>> # `KIND=7'
>> # This is valid only as `INTEGER(KIND=7)' and denotes the `INTEGER'
>> # type that has the smallest storage size that holds a pointer on
>> # the system.
>>
>> So, g77's STATUS argument is wide enough to hold a pointer.
>> gfortran's isn't in all cases. This is a bug.
>>
>
> gfortran doesn't have an INTEGER(KIND=7), and after reading
> g77.info adding such a type would probably violate numerous
> parts of the Fortran standard.
FWIW I agree with Thomas and Jack that this is a bug. If signal always
truncates the result to default integer it's clearly broken on 64-bit
platforms. IMHO the correct solution would be to have signal status big
enough and let the compiler truncate in case the user calls the
procedure with a default kind argument/assigns the function result to a
default integer/ on 64-bit platforms. Maybe we need something like
GFC_INTEGER_INTPTR_T in kinds.h?
--
Janne Blomqvist
More information about the Fortran
mailing list