Skip to content

Value initialization not working #134

@christianbrugger

Description

@christianbrugger

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<int> 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<int> {};  // uninitialized

See on godbolt.

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<int> x;
    safe<int> y;
};
const auto p = Point {};  // uninitialized

See on godbolt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions