Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

add overflow checks for MT_UNSIGNED, MT_NEGATIVE and MT_TAG #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

detmat
Copy link

@detmat detmat commented Jan 24, 2018

No description provided.

@pyropeter
Copy link

GCC 4.8.4 was released December 19, 2014.

@pyropeter
Copy link

pyropeter commented Jan 24, 2018

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.

@cabo
Copy link
Owner

cabo commented Jan 28, 2018

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

@jimsch
Copy link
Contributor

jimsch commented Apr 16, 2018

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

@pyropeter
Copy link

@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?

@jimsch
Copy link
Contributor

jimsch commented Apr 16, 2018

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants