cn-cbor icon indicating copy to clipboard operation
cn-cbor copied to clipboard

add overflow checks for MT_UNSIGNED, MT_NEGATIVE and MT_TAG

Open detmat opened this issue 7 years ago • 6 comments

detmat avatar Jan 24 '18 16:01 detmat

GCC 4.8.4 was released December 19, 2014.

pyropeter avatar Jan 24 '18 16:01 pyropeter

Oh, and __builtin_add_overflow is supported since GCC 5.0.1, released April 22, 2015.

GCC 5 is too new for the oldest LTS releases of Debilian and Ubuntu, which both will reach EOL in the middle of 2018 and 2019 respectively.

pyropeter avatar Jan 24 '18 16:01 pyropeter

So how can we do this in a way that leaves a version that conforms to the C standards?

cabo avatar Jan 28 '18 12:01 cabo

__builtin_add_overflow is not supported by my MSVC compiler. I would not be in favor of this.

jimsch avatar Apr 16 '18 03:04 jimsch

@jimsch It would be interesting to know: how do you do overflow checks? Does MSVC have similar builtins? Do they have library functions doing integer overflow checking?

pyropeter avatar Apr 16 '18 06:04 pyropeter

I am not aware of any such function that is part of MSVC. The few times that I have cared about it I have always written specific code for that addition. Usually by adding in a longer int and checking the result. The need to make sure that things run on all the different architectures targeted.

jimsch avatar Apr 16 '18 19:04 jimsch