Comments (2)
More context:
- An error like this is also known as a
truncating conversion
. Is is not undefined behavior, but it is usually unwanted behavior that should be protected from - The only current way to detect it is with the
-Wconversion
warning. However the use ofstatic_cast
will silence this warning making it hard to detect (this is why I recommend manual detection and throwing based onnumeric_cast
).
There is some discussion of adding support for assignment based detection of truncating conversion in clang++: http://clang-developers.42468.n3.nabble.com/A-need-for-an-quot-fsanitize-integer-assign-overflow-quot-td4037252.html#a4037318
Looks like this library might have what we need: https://cs.chromium.org/chromium/src/base/numerics/README.md
Or this one: https://github.com/narizhny/numeric_safety
from carmen-cache.
Closing, since this is more of a discussion piece than actionable. This ticket was created to discuss ways to avoid bugs like #82, but in reality tooling can't really catch all these bugs and unit tests are the way to ensure correct behavior (which we now have for #82).
from carmen-cache.
Related Issues (20)
- [setgrid] Add unit tests for _set() with grid objects HOT 1
- [setgrid] Add an encodeGrid() cpp method HOT 1
- [setgrid] Wire up encodeGrid() and _set() HOT 1
- [setgrid] Building dev binaries HOT 1
- Flapping test failures in asan travis job HOT 1
- Refactor Plan HOT 9
- Refactor followup: enable LTO HOT 7
- Use `-Werror` and `-isystem` HOT 3
- Speed up sorting / reduce overhead of sorting HOT 1
- Illegal instruction on Node 8 HOT 3
- Documenting most recent bottlenecks detected HOT 3
- Don't publish binaries for git tags HOT 2
- Update scoredist implementation
- Refactor coalesce to reduce duplicate get operations
- Review Travis CI and Warning options.
- Place of binary
- Update RocksDB: 4.13 -> 5 HOT 4
- Upstream: undo feature id sharding HOT 3
- [setgrid] Set Grid Quest HOT 1
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 carmen-cache.