Skip to content

Make intptr_union an std::variant #12

@Nydauron

Description

@Nydauron

Currently, we've modified intptr_union to be the following definition:

typedef struct {
    int i;
    void *p;
    std::shared_ptr<char> s;
} intptr_union;

before that change, it was:

typedef union {
    int i;
    void* p;
} intptr_union;

This change was made to help fix some memory leaks within the parser.

We ideally want to wrap all 3 different types in a std::variant since that behaves exactly like union but allows for objects to be constructed/destructed, but currently, there some Spim test files that are causing the parser to panic due to a mismatch of type assert. If we can, we should add type checking before we unwrap the std::variant and handle accordingly if it is a different value.

To see what it was like when we first tried to use std::variant see acdfc84.
Note that commit 155e9ab reverted these changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions