This appears to be a false positive.

According to:

https://msdn.microsoft.com/en-us/library/9t02bbsx.aspx

...the warning is generated because "If the shift overflowed the 32-bit value, 
bits are lost." But that's what is actually intended in bitop (it's a 32-bit 
bit operations library).

I believe the error gets flagged by MSVC because of this line in lua_bitop.c, 
line #96:

#define BRET(b)  lua_pushnumber(L, (lua_Number)(SBits)(b)); return 1;

...since 'b' resolves to (b << n), and lua_Number is a double, then line #116 
ends up being this:

static int bit_lshift(lua_State *L) {
    uint32_t b = barg(L, 1);
    uint32_t n = barg(L, 2) & 31;
    lua_pushnumber(L, (double)(int32_t)(b << n));
    return 1;
}

So MSVC doesn't like that lua_pushnumber() line, apparently.  But that's the 
intended behavior, because Lua numbers are doubles.

-hadriel


On Feb 7, 2015, at 4:54 PM, Bill Meier <wme...@newsguy.com> wrote:

> Hadriel:
> 
> MSVC2013 Code Analysis is giving the following warning:
> 
> 
> ...\ws-git\epan\wslua\lua_bitop.c(116) : warning C6297: Arithmetic overflow:  
> 32-bit value is shifted, then cast to 64-bit value.  Results might not be an 
> expected value.
> 
> After quick look at the code, my reaction:
>  Uh Oh... Twisty maze of passages
> 
> So I'm going to punt.
> 
> Can you take a look (or redirect upstream) or whatever ?
> 
> Thanks
> 
> Bill

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@wireshark.org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe

Reply via email to