> Roger Binns wrote on Sunday, September 07, 2014 2:30 PM
> On 07/09/14 11:19, Richard Hipp wrote:
> > Please use a cast to silence the compiler warnings.
> "(int)sizeof(...)"
> > instead of just "sizeof(...)".
> 
> That isn't safe for correctly written 64 bit apps.  For example they
> could end up with data items that are bigger than 2GB correctly using
> (s)size_t.
> The silencing cast above would then truncate it to a negative 32 bit
> number or truncated 31 bit number, which has differing meanings in the
> SQLite 3 APIs, and certainly never matches the callers intention.
> 
> The only safe thing for a correctly written 64 bit app to do is ensure
> that all size values are less than 2GB, and then the warning can be
> silenced in a cast.
> 

If the Boost C++ libraries are available, there's a numeric_cast that does 
casting and checks for overflow in the process.

It's not worth adding all of Boost for just this little bit, but if you have it 
around, may be worth taking a look.

----------------------------------------------------------------------
This message, and any attachments, is for the intended recipient(s) only, may 
contain information that is privileged, confidential and/or proprietary and 
subject to important terms and conditions available at 
http://www.bankofamerica.com/emaildisclaimer.   If you are not the intended 
recipient, please delete this message.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to