Silverfrost Forums

Welcome to our forums

integer*1 range problems

30 Jun 2008 2:37 #3432

On v 5.21, yhe following generates a 'reference to undefined variable' error at the print when using a checkmate build. A breakpoint set on the print shows i1 as 'undefined':

integer*1:: i1 i1 = 0 i1 = ibset(i1, 7) print *, i1

When running a debug build i1 is still shown as undefined in the debugger, but the program doesn't stop and prints the correct -128.

The problem doesn't seem to occur when setting the top bit on an integer*2 or *3.

1 Jul 2008 9:15 #3437

Thank you for the bug report. We will investigate this as soon as we can.

18 Jul 2008 3:02 #3478

inset(i1, 7) gives Z'80' which is 128 and is out of range.

It also happens to be the 'undefined' state used by FTN95 for INTEGER*1 variables.

21 Jul 2008 5:17 #3510

Erm, I've alway known Z'80' in a signed 8-bit integer to be -128 - a single signed byte's range being -128 to +127. The ftn95 help under 'Arithmetic overflow checking' also has this for INTEGER(KIND=1). I can see how you might argue that ibset is casting from a >8 bit integer in which case it would be out of range (although I'd argue that is not correct since all I want to do is set bit 7 of the variable and I shouldn't need to consider what's going on within ibset) - wouldn't that then generate an overflow ?

I do buy the 'undefined' explanation for checkmate build however, and that does explain the checkmate problem, however I don't see that the debugger has a problem with it in my debug builds as I don't have /undef enabled in (I can't use undefined variable checks as my program processes binary data - which is a pity).

21 Jul 2008 5:31 #3511

What I should have said was that the assignment i1 = Z'80' where i1 is INTEGER1, is flagged by the compiler as out of range because the default integer size on the RHS is INTEGER4. So the RHS is 128 and the assignment is out of range.

I will take another look at it and report back.

25 Jul 2008 6:55 #3569

This bug/limitation has be removed for the next release.

Please login to reply.