You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] emitted initialisation of base class in member initialiser list of derived copy constructor does not compile #402
Describe the bug
If, within a class hierarchy, a derived type has an operator=: (out this, that), then the lowered cpp1 code will attempt to initialise the base class using that.Base as if Base were a member.
To Reproduce
Steps to reproduce the behavior:
Sample code - distilled down to minimal essentials please
The following cpp2 code:
Base : type = {
operator=: (out this, that) = {}
}
Derived : type = {
this: Base = ();
operator=: (out this, that) = {}
}
will produce the following function definition for the copy constructor of Derived in cpp1:
5. Expected result - what you expected to happen
I would expect the copy constructor to be emitted as
Derived::Derived(Derived const& that)
: Base{ that }
{}
and that the emitted code would compile
I think the access should be explicit
to prevent a templated constructor from being chosen over the copy constructor,
i.e., : Base{ static_cast<Base const&>(that) } rather than : Base{ that }.
Activity
JohelEGP commentedon May 1, 2023
I think the access should be explicit
to prevent a templated constructor from being chosen over the copy constructor,
i.e.,
: Base{ static_cast<Base const&>(that) }rather than: Base{ that }.A little more self-hosting: `meta::object_declaration` to Cpp2
JohelEGP commentedon May 31, 2023
Fixed by 59fc520,
but not the way I suggested: https://cpp2.godbolt.org/z/Pboceoorz.
A templated constructor is chosen over a special member function.