[Bug fortran/29926] interface overloading assignment does not handle input types correctly

burnus at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Nov 21 17:55:00 GMT 2006



------- Comment #1 from burnus at gcc dot gnu dot org  2006-11-21 17:55 -------
> test.f90:10.12:
>   b = uword(int(65535,kind=4))
>            1
> Error: Arithmetic overflow converting INTEGER(4) to INTEGER(2) at (1)

This is invalid Fortran as 65535 does not fit into a kind=2 integer.
If you want to allow it, use the "-fno-range-check" option.

> Note that the overloading of dummy does not return an error, but the
> assignment interface chooses the the wrong module procedure.

I probably miss the point, but:
  a = uword(int(1024,kind=2))

Here, you create a kind=2 integer and convert it to a type(uword); this is then
 assigned using the intrinsic operator(=) to "a".

  b = uword(int(65535,kind=4))

The same here, but converting int(65535,kind=4) to kind=2 overflows. The kind=2
value is then assigned (intrinisc "=") to b.

You probably want to use your uword_assign_* subroutines. Then you should use:
  a = int(1024,kind=2)
  b = int(65535,kind=4)

In any case, gfortran returns the same result as ifort, g95, NAG f95 or sunf95.
(Which accept the integer overflow either with or without warning.)

Can this bug be closed as INVALID or did I miss something and there is a real
bug burried somewhere?


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29926



More information about the Gcc-bugs mailing list