boostorg / boostorg/safe_numerics
Value initialization not working
- Dominant language
- C++
- Stars
- 222
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Description
I am not sure if technically a bug, but from the documentation and talks what I understood was that in my code I can basically replace `int` with `safe` and it should compile and give the same result with checks.
I get into problems related to default initialization.
#### 1. Default Initialization
```
auto x = int {}; // zero initialized
auto y= safe {}; // uninitialized
```
See on [godbolt](https://godbolt.org/z/G8d9ehW3n).
#### 2. Aggregate Initialization
This is obviously related, and I want to mention it, as this is how it came to my attention.
```
struct Point {
int x;
int y;
};
const auto p = Point {}; // zero initialized
```
With `safe<>`
```
struct Point {
safe x;
safe y;
};
const auto p = Point {}; // uninitialized
```
See on [godbolt](https://godbolt.org/z/q966cPf1W)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.