Issue 93405
Summary Aggregate initialization of an immovable base with a prvalue attempts to call the deleted copy constructor
Labels new issue
Assignees
Reporter JankoDedic
    Works on GCC and MSVC.

Godbolt link: https://godbolt.org/z/KdETMao9K

Code that reproduces the issue:

```cpp
#include <type_traits>

struct Immovable
{
    Immovable() = default;

    Immovable(const Immovable&) = delete;

    Immovable&
    operator=(const Immovable&) = delete;
};

class Base
{
    Immovable immovable;

public:
    Base
    clone()
    {
 return Base{};
    }
};

struct Derived:
    Base
{
 Derived
    clone()
    {
        return Derived{Base::clone()};
 }
};

static_assert(std::is_aggregate_v<Derived>);

int
main()
{
 Derived d0;
    Derived d1 = d0.clone();
}
```

Error message:

```
<source>:31:24: error: call to implicitly-deleted copy constructor of 'Base'
   31 |         return Derived{Base::clone()};
 |                        ^~~~~~~~~~~~~
<source>:15:15: note: copy constructor of 'Base' is implicitly deleted because field 'immovable' has a deleted copy constructor
   15 |     Immovable immovable;
      | ^
<source>:7:5: note: 'Immovable' has been explicitly marked deleted here
    7 |     Immovable(const Immovable&) = delete;
      | ^
1 error generated.
Compiler returned: 1
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to