         Edinburgh IMP77 Compiler - Version 8.4

    1  %begin
    2  
    3    ! First the shortinteger -> integer case, which has always worked:
    4  
    5    %shortinteger smax = 16_7FFF * 2
    6    ! Should either give an integer overflow error if overflow trapping is enabled or evaluate to an erroneous negative value
    7    write(smax, 0) ; newline
    8  
    9    ! Unlike the similar case with %longinteger, this is OK because all int constants are evaluated as %integer
   10    ! and not one of the smaller integer types.  It's only integer types *larger* than default %integer which
   11    ! cause problems with propogating their type upwards.
   12    %integer ismax1 = 16_7FFF * 2
   13    write(ismax1, 0) ; newline
   14  
   15    ! So this works too.
   16    %integer ismax2 = 16_7FFF ; ismax2 = ismax2 * 2
   17    write(ismax2, 0) ; newline
   18  
   19  
   20    ! and then the integer -> longinteger case, which I'm not so sure about.  This must have been
   21    ! seen on EMAS 2900 which also supported %longinteger - Bob, what did EMAS do?
   22  
   23  
   24    %integer max = 16_7FFFFFFF * 2
   25    ! Should either give an integer overflow error if overflow trapping is enabled or evaluate to an erroneous negative value
   26    write(max, 0) ; newline
   27  
   28    ! Unfortunately imp does type coercion bottom up so int X int -> int, which is then assigned to a longinteger and truncated.
   29    %longinteger imax1 = 16_7FFFFFFF * 2
   30    write(imax1, 0) ; newline
   31  
   32    ! This workaround is needed in order to do what is expected.   Not a bug but due to the way Imp77 is defined.
   33    %longinteger imax2 = 16_7FFFFFFF ; imax2 = imax2 * 2
   34    write(imax2, 0) ; newline
   35  
   36  
   37  %endofprogram

   22 Statements compiled
