Closed
Description
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:
Derived::Derived(Derived const& that)
: Base{ that.Base }
{}
This will not compile.
2. Command lines including which C++ compiler you are using
cppfront is compiled with gcc12 and executed using
cppfront -p my_file.cpp2 -o stdout
The emitted cpp1 is also being compiled with gcc12.
- 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
- Actual result/error5.
The emitted code refers to the base class asthat.Base
and does not compile with the following error on gcc:
<source>:35:49: error: invalid use of 'Base::Base'
35 | : Base{ that.Base }
| ^~~~
<source>:35:54: error: no matching function for call to 'Base::Base(<brace-enclosed initializer list>)'
35 | : Base{ that.Base }
|