Comments (1)
The following changes seem to fix the issue.
#define nimAddInt64(a, b, res) __builtin_add_overflow(a, b, res)
#define nimSubInt64(a, b, res) __builtin_sub_overflow(a, b, res)
#define nimMulInt64(a, b, res) __builtin_mul_overflow(a, b, res)
#define nimAddInt(a, b, res) __builtin_add_overflow(a, b, res)
#define nimSubInt(a, b, res) __builtin_sub_overflow(a, b, res)
#define nimMulInt(a, b, res) __builtin_mul_overflow(a, b, res)
the test:
discard """
targets: "c cpp"
"""
# Bug #23894
proc checkSucc(tp: typedesc) =
let v = high(tp)
let v2 = tp(uint64(v) div uint64(2))
let v3 = succ v2
discard v3
proc checkSuccOverflow(tp: typedesc) =
let v = high(tp)
try:
let v2 = succ v
discard v2
except OverflowDefect:
return
doAssert false, "unreachable"
block: # overflow
checkSuccOverflow(char)
checkSuccOverflow(cint)
checkSuccOverflow(cuint)
checkSuccOverflow(csize_t)
checkSuccOverflow(uint)
checkSuccOverflow(uint8)
checkSuccOverflow(uint16)
checkSuccOverflow(uint32)
checkSuccOverflow(uint64)
checkSuccOverflow(int)
checkSuccOverflow(int8)
checkSuccOverflow(int16)
checkSuccOverflow(int32)
checkSuccOverflow(int64)
checkSuccOverflow(cint)
checkSuccOverflow(cuint)
checkSuccOverflow(csize_t)
block: # should't overflow
checkSucc(char)
checkSucc(cint)
checkSucc(cuint)
checkSucc(csize_t)
checkSucc(uint)
checkSucc(uint8)
checkSucc(uint16)
checkSucc(uint32)
checkSucc(uint64)
checkSucc(int)
checkSucc(int8)
checkSucc(int16)
checkSucc(int32)
checkSucc(int64)
from nim.
Related Issues (20)
- `koch pdf` produces a warning about unknown substitution 'nimversion'
- `nim gendepend` does not work with var-less destructors
- When JS, operations on pointer casted from ref object raises Runtime-Errors
- Regression - cannot instantiate Maybe generic arguments are missing HOT 5
- Identifier expected or compiler segfault with templates over generic type in type section HOT 3
- Nested generic/static parameter: undeclared identifier in typesections HOT 2
- 2.2.0 rc1 regression with cdecl functions
- Warnings missing when compiling the same file twice HOT 4
- `genericsOpenSym` not working when additional generally non-matching symbol with same name is present HOT 1
- nimsuggest crashes when using `--mm:arc/orc` and if an object that contains `string` or `seq` is constructed HOT 2
- ARC hooks missing when sinking generic typeclass HOT 3
- Generic concepts not compatible with openarray HOT 2
- os module uses wrong path separator in nimvm when cross-compiling HOT 2
- Objects can protect illegal recursion but tuples cant HOT 4
- Extract/move can cause SIGSEGV error when used with 2D sequences HOT 6
- Nested dirty template in generic proc HOT 11
- Disambiguating module of template call with shared symbol prevents building
- Useless empty C files with arc/orc
- Identifier exported as typename in one module and `template` in another can't be used in `template`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nim.