Joined: 31 Oct 2006
|Posted: Sun Jun 21, 2020 4:39 am Post subject: Buggy behaviour of SDBG64
|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.
INTEGER, PARAMETER :: NLEN=7
CHARACTER(LEN=1) :: uchar
CHARACTER(LEN=NLEN) :: name
name = 'eld.dat'
uchar = uchar1(name)
PRINT *,'First character,upper-cased: ',uchar
FUNCTION uchar1(string) RESULT(u1)
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
END FUNCTION uchar1