Discussion:
[soci-users] Behavior when signed numeric type is to small with soci::into
Klemm, Markus
2015-08-18 11:27:47 UTC
Permalink
What will soci do when I have for example an signed int with a width of 32 bit and binds it to the output via soci::into, to a query, which yields a high signed value.
I assume I will get a soci_error or the soci::indicator is set to i_truncated if the value is > 2^32-1, but will this happen also if the value is 2^31-1 < x < 2^32-1 or will I get a overflow?

Mit freundlichen Grüßen / Best regards

Markus Klemm
Technology & Development
Vadim Zeitlin
2015-08-24 12:29:41 UTC
Permalink
On Tue, 18 Aug 2015 11:27:47 +0000 "Klemm, Markus" <***@cicor.com> wrote:

KM> What will soci do when I have for example an signed int with a width of
KM> 32 bit and binds it to the output via soci::into, to a query, which
KM> yields a high signed value. I assume I will get a soci_error or the
KM> soci::indicator is set to i_truncated if the value is > 2^32-1, but
KM> will this happen also if the value is 2^31-1 < x < 2^32-1 or will I get
KM> a overflow?

To be honest, I don't know what happens in this case and I'm not even sure
if the behaviour is the same across all backends. It would be nice to add a
unit test checking for it and then ensuring that they all do behave in the
same way.

Regards,
VZ

Loading...