Silverfrost Forums

Welcome to our forums

Buggy behaviour of SDBG64

21 Jun 2020 3:39 #25733

SDBG64, version 8.62a, exhibits inconsistent behaviour when running the following program after the program was compiled using the FTN95 8.62.1 compiler with the /debug /64 options.

When the program is run up to a breakpoint set on line 27, the variables pane shows '0' for U1 instead of the correct value, 'E'. The debugger seems to think that U1 is REAL, rather than CHARACTER(1).

The same program, compiled with /check /64 and run with SDBG64, displays further odd behaviour. Initially, line 8 is highlighted. Pressing F7 twice moves the highlight to line 11, as if the body of function UCHAR1 was never entered. Pressing F7 again moves the highlight to line 20; note that U1 is shown as UNDEFINED. Pressing F7 four times moves the highlight to line 28, and the value of U1 is shown as -1.1801e-038, which was probably inferred from the bit pattern Z'80808080' used as the signature of 'UNDEFINED'. A 1-byte character variable is being seen as a 4-byte real variable. Pressing F7 once more returns control to line-10, and UCHAR now has the correct value 'E'.

The program is just a demonstrator, and rather meaningless otherwise.

Program UpCase
  IMPLICIT NONE
  INTEGER, PARAMETER :: NLEN=7
  CHARACTER(LEN=1) :: uchar
  CHARACTER(LEN=NLEN) :: name
!
  name = 'eld.dat'
  uchar = uchar1(name)
  PRINT *,'First character,upper-cased: ',uchar
  STOP

CONTAINS

FUNCTION uchar1(string) RESULT(u1)
  IMPLICIT NONE
  CHARACTER(LEN=*), INTENT(IN) :: string
  CHARACTER(LEN=1) :: u1, ch
  INTEGER, PARAMETER :: lower_to_upper = IACHAR('A') - IACHAR('a')
  ch = string(1:1)
  IF('A' <= ch .AND. ch <= 'Z') THEN
     u1 = ch
  ELSEIF('a' <= ch .AND. ch <= 'z') THEN
     u1 = ACHAR(IACHAR(ch) + lower_to_upper)
  ELSE      ! ... not alphabetic
     u1 = ch
  ENDIF
  RETURN
END FUNCTION uchar1

END PROGRAM
22 Jun 2020 6:18 #25744

Thank you for the report.

Please login to reply.