Skip to content

[BUG] Union metaclass does not provide copy constructors/allows supplied copy constructors #770

Closed
@KendallHarter

Description

@KendallHarter

The union metaclass currently does not provide copy constructors nor does it prevent the user from defining them, causing incorrect copy semantics.

To Reproduce

test: @union type = {
   operator=: (out this) = {}
   operator=: (out this, that) = {}
   name: std::string;
}

main: () -> int = {
   var: test = ();
   var.set_name("");
   var2 := var;
}

Commands:

./cppfront test.cpp2
g++11.3 -I ./include/ -std=c++20 test.cpp
./a.out

Expected result:
Code either fails to compile due to provided copy constructor or copy semantics are correctly implemented.

Actual result/error:
Memberwise copy is performed, creating an invalid object.

free(): invalid pointer
Aborted

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions