jyknight wrote:

This PR does resolve some of the errors in this area, but does not seem to 
resolve my previously-reported issue:
```
#include <memory>

struct X;

struct Y {
    Y() {}
    std::unique_ptr<X> member_;
};

struct X {  int a; };
```
With this patch applied, `clang -std=c++23 -fsyntax-only` still emits the 
following diagnostics:
```
include/c++/v1/__memory/unique_ptr.h:72:19: error: 
      invalid application of 'sizeof' to an incomplete type 'X'
   72 |     static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
      |                   ^~~~~~~~~~~
include/c++/v1/__memory/unique_ptr.h:288:7: note: 
      in instantiation of member function 'std::default_delete<X>::operator()' 
requested here
  288 |       __deleter_(__tmp);
      |       ^
include/c++/v1/__memory/unique_ptr.h:254:71: note: 
      in instantiation of member function 'std::unique_ptr<X>::reset' requested 
here
  254 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { 
reset(); }
      |                                                                       ^
test.cc:6:5: note: in instantiation of member function 
'std::unique_ptr<X>::~unique_ptr' requested here
    6 |     Y() {}
      |     ^
test.cc:3:8: note: forward declaration of 'X'
    3 | struct X;
      |        ^
1 error generated.
```

`gcc -std=c++23` compiles it successfully, as does `clang -std=c++20` (because 
`~unique_ptr` isn't marked constexpr in C++20).

Here's a test-case without library headers:
```
template <typename T>
struct unique_ptr {
    constexpr ~unique_ptr() {
        static_assert(sizeof(T));
    }
    T* ptr;
};

struct X;

struct Y {
    Y() {}
    unique_ptr<X> member_;
};

struct X {  int a; };
```


https://github.com/llvm/llvm-project/pull/173537
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to