BlindMindStudios / AngelScript-JIT-Compiler

A Just-In-Time compiler for the AngelScript language on x86 processors.
www.blind-mind.com
238 stars 49 forks source link

Warning C4267 #21

Closed Jastonite closed 8 years ago

Jastonite commented 8 years ago

This is a minor issue, but I use the Microsoft VC++ compiler, and I have have the warning level set to 4 (which includes 4xxx warnings). This line (file: as_jit.cpp line: 3800) issues a C4267 warning: "conversion from 'size_t' to 'unsigned int', possible loss of data.

#ifdef _MSC_VER
        unsigned offset = ((size_t)func->func) >> 2;
        offset *= sizeof(void*);

        as<void*>(pax) += offset;
        as<void*>(pax) = as<void*>(*pax);
#endif

To me it looks like the conversion is safe in this context, but it would be nice to address the warning. I am currently using this patch:

#ifdef _MSC_VER
        unsigned offset = (unsigned)(((size_t)func->func) >> 2);
        offset *= sizeof(void*);

        as<void*>(pax) += offset;
        as<void*>(pax) = as<void*>(*pax);
#endif