https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114076

            Bug ID: 114076
           Summary: list-initialization with assignment expression
                    triggers wrong template instanciation
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: benni.buch at gmail dot com
  Target Milestone: ---

I come from this Bug Report to Visual C++:

- https://github.com/microsoft/STL/issues/4417

I think that GCC has a similar bug here.

```cpp
template <typename T>
struct holder {
    holder() = default;

    constexpr ~holder() {
        static_assert(sizeof(T) || true);
    }
};

struct Incomplete;

struct Class {
    Class();
    ~Class();

    holder<Incomplete> a{};
    holder<Incomplete> b = {};
    //holder<Incomplete> c = holder<Incomplete>{};
};

int main() {
    [[maybe_unused]] Class v;
}
```

- https://godbolt.org/z/ds3WYK55f

Cases a and b can both be compiled with Clang. GCC rejects b, which is wrong in
my opinion.

If I understand it correctly, then cases a and b should result in absolutely
identical initializations. The destructor of holder should not be instantiated.

In case c, the rejection seems to me to be correct, since here the temporary
value must be destroyed by a destructor call.

Among other things, this error affects unique_ptr.

Reply via email to