Silverfrost Forums

Welcome to our forums

scc crash (register-memory emit for MULSS)

4 Jul 2018 12:20 #22317

The following code causes scc to crash if compiled using scc with option /64 set and USE_GETTICKCOUNT defined. The code is given by

#include <windows.h>

int myProc(int myParm)
{
#ifdef USE_GETTICKCOUNT
	static float lastTime = GetTickCount() * 0.001f;
#else
	static float lastTime=0.001f;
#endif
	return 0;
}

and it is named 'scc_crash.cpp'. Executing command

scc scc_crash.cpp /64 /DEFINE USE_GETTICKCOUNT

makes scc crash and display the lines

[Silverfrost SCC/WIN32 Ver 4.20 Copyright (c) Silverfrost Ltd 2018]
   0006         static float lastTime = GetTickCount() * 0.001f;
COMMENT - This initialisation will be performed once only
WARNING - 'lastTime' has been given a value, but never used
   0003   int myProc(int myParm)
WARNING - 'myParm' has not been used
   0011   }
*** Failed to do register-memory emit for MULSS at 8
*** Failed to do memory-register emit for MOVSS at 9
    2 ERRORS  [<SCC_CRASH> SCC/WIN32 Ver 4.20]
*** Compilation failed

An object file SCC_CRASH.OBJ is generated, however, its length is 0. An error file for the crash has been created consisting of the lines

Runtime error from program:c:\win32app\silverfrost_8.30\ftn95\scc.exe
Breakpoint
Breakpoint at address 004a8d45

 004a8aed amd_do_type_conversion(<ptr>struct&#9472;tree_record) [+0258]

 004a0c14 AmdCodeGenerator(<ref>struct&#9472;tree_ptr) [+4321]

 004a7418 amd_do_times(<ptr>struct&#9472;tree_record) [+0044]

 004a0c14 AmdCodeGenerator(<ref>struct&#9472;tree_ptr) [+4321]

 004a7a82 amd_do_equals(<ptr>struct&#9472;tree_record) [+0073]

 004a0c14 AmdCodeGenerator(<ref>struct&#9472;tree_ptr) [+4321] [recur=  2] 

 004a837b amd_do_function_top(<ptr>struct&#9472;tree_record) [+0309]

 004a0c14 AmdCodeGenerator(<ref>struct&#9472;tree_ptr) [+4321]

 0048aaf6 code_generator(<ref&รทw>Ysu
eax=0ae09668   ebx=00000005   ecx=00000019
edx=00000007   esi=0ae09688   edi=0000004b
ebp=0377e84c   esp=0377e810   IOPL=0
ds=002b   es=002b   fs=0053
gs=002b   cs=0023   ss=002b
flgs=00000297 [CA EP NZ NS DN NV]

 004a8d45  int    3  
 004a8d46  jmp      4a8e6c 
 004a8d4b  push     0xf0f0f0f0 

. Each of the commands

scc scc_crash.cpp /64
scc scc_crash.cpp /DEFINE USE_GETTICKCOUNT
scc scc_crash.cpp

worked successfully and created an object file SCC_CRASH.OBJ with postive length. This makes me suspect that GetTickCount causes problems for the 64 bit compile.

Regards, Dietmar

4 Jul 2018 12:59 #22318

Dietmar

A work-around is to cast the return DWORD value of GetTickCount to an int...

   static float lastTime = (int)GetTickCount() * 0.001f; 

The code seems strange to me since I assume the call is made only once when the application is loaded.

4 Jul 2018 2:29 #22320

Paul,

thanks for the work-around which made the 'critical' sample be compiled successfully. I know that the static declaration had better been moved outside the function. I had given it a chance but the result was the same. Nevertheless this should not matter ... as you said this code (initializing lastTime) should be made only once.

Regards, Dietmar

Please login to reply.