lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Resending in plaintext.

________________________________
> From: ianjirka@hotmail.com 
> To: lua-l@lists.lua.org 
> Date: Fri, 18 Oct 2013 22:37:09 -0700 
> Subject: Avoiding VC++ assertions when truncating values 
> 
> Hello, 
> 
> I noticed when compiling LUA in 64-bit in VS 2013 (VC++ 18.00.21005.1), 
> the compiler will generate 
> assertion code when it detects value truncation. 
> 
> It is specifically the IntPoint macro that is affected. The 
> recommended solution (as described by the assertion) is to explicitly 
> truncate the value before casting it to a narrower value type. 
> 
> The diff below worked for me, at least for the code coverage I have. 
> 
> llimits.h:44 
> <#define IntPoint(p) ((unsigned int)(lu_mem)(p)) 
>>#define IntPoint(p) (unsigned int)(((lu_mem)(p)) & UINT_MAX) 
> 
> FWIW, the message generated by the VCRT is: 
> 
> "Run-Time Check Failure #1 - A cast to a smaller data type has caused a 
> loss of data. If this was intentional, you should mask the source of 
> the cast with the appropriate bitmask. For example: 
> char c = (I & 0xFF); 
> Changing the code in this way will not affect the quality of the 
> resulting optimized code." 
> 
> Cheers, 
> 
> -Ian