Tested on rev1549. The bug is sporadic and difficult to pinpoint, its root cause is likely in the bytecode generation rather than bytecode restoration. In a script with a registerd value-type variable placed in the global scope, sometimes another function is called instead of the variable's type constructor when the script is loaded from the bytecode.
Loading the script from the source is without problems. When loading from the generated bytecode, it either works correctly all of the time (for that generated bytecode), or it consistently calls the same, wrong function (which has no special relation to the correct one). Whether the bytecode is buggy or not seems to depend on things like order of compilation of scripts or whether some script was compiled prior to the one in question.
Calling the wrong function naturally leads to bad behaviour, here is the call stack I get when I stumble upon a resulting crash:
CallCDeclFunctionObjFirst + 38, as_callfunc_x86.cpp (494) CallSystemFunctionNative + 885, as_callfunc_x86.cpp (207) CallSystemFunction + 294, as_callfunc.cpp (486) asCContext::ExecuteNext + 2756, as_context.cpp (2450) asCContext::Execute + 521, as_context.cpp (1158) asCModule::CallInit + 337, as_module.cpp (310) asCModule::ResetGlobalVars + 31, as_module.cpp (254) asCReader::Read + 278, as_restore.cpp (98) asCModule::LoadByteCode + 111, as_module.cpp (1189)
Maybe it is important that there could be some functions etc. that are registered to the engine after some scripts are already compiled (or loaded from the bytecode). This never caused any problems before though. For the record, the value-type in question is registered this way:
if(ASEngine->RegisterObjectType("FuncBind", sizeof(ScriptFuncBind), asOBJ_VALUE) < 0) Log("%s FuncBind\n", fail); if(ASEngine->RegisterObjectBehaviour("FuncBind", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ScriptFuncBind_Construct), asCALL_CDECL_OBJFIRST) < 0) Log("%s FuncBind ctor\n", fail); if(ASEngine->RegisterObjectBehaviour("FuncBind", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(ScriptFuncBind_Destruct), asCALL_CDECL_OBJFIRST) < 0) Log("%s FuncBind dtor\n", fail);