Silverfrost Forums

Welcome to our forums

Problem with fgetc with SCC /64

2 May 2019 2:57 #23569

It appears that the routine fgetc returns different values when compiled with the 64bit SCC compiler than under the 32bit SCC compiler.

A simple test using fputc and fgetc using the byte values 1 to 255; with the 32bit compiler it returns 1 to 255, but the 64 bit compiler returns 1 to 127 and then -128 to -1!

:?

3 May 2019 1:38 #23573

The bug is in the fgetc code in salflibc64.dll. Ten instructions before the RET instruction of fgetc(), we see

000000001C009315  movsx       r15,byte ptr [rsp+20h]   ; sign bit got extended
000000001C00931B  mov         rax,r15 

The corresponding code in the 32-bit salflibc.dll is

1001C5FA: 8A45EA               mov al, [ebp-16]
1001C5FD: 0FB6C0               movzx eax, al  ; zero extended to upper 24 bits of EAX

The return value from fgetc() is 0 to 0xFF, zero-extended to integer size, when there is no I/O error. One or more of bits 8-31 should be set only if an I/O error occurs.

3 May 2019 6:06 #23574

Thank you for the reports. It should be easy for us to fix.

3 May 2019 6:44 #23575

This has now been fixed but not in time for the 8.50 release.

Please login to reply.