Closed
Description
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