Skip to content
This repository was 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
detmat wants to merge 1 commit into
cabo:masterfrom
beduino-project:add_overflow_checks
Open

add overflow checks for MT_UNSIGNED, MT_NEGATIVE and MT_TAG#44
detmat wants to merge 1 commit into
cabo:masterfrom
beduino-project:add_overflow_checks

Conversation

@detmat

@detmat detmat commented Jan 24, 2018

Copy link
Copy Markdown

No description provided.

@pyropeter

Copy link
Copy Markdown

GCC 4.8.4 was released December 19, 2014.

@pyropeter

pyropeter commented Jan 24, 2018

Copy link
Copy Markdown

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

cabo commented Jan 28, 2018

Copy link
Copy Markdown
Owner

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

@jimsch

jimsch commented Apr 16, 2018

Copy link
Copy Markdown
Contributor

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

@pyropeter

Copy link
Copy Markdown

@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

jimsch commented Apr 16, 2018

Copy link
Copy Markdown
Contributor

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