Issue 175483
Summary potentially incorrect `error: invalid application of 'sizeof' to an incomplete type` with `-std=c++23`
Labels clang:diagnostics, c++23, diverges-from:gcc, diverges-from:msvc
Assignees
Reporter firewave
    ```cpp
#include <memory>

class C
{
public:
    C();
    ~C();

private:
    struct Impl;
    std::unique_ptr<Impl> mImpl;
};

C::C() = default;
C::~C() = default;
struct C::Impl {};
```

This fails with `-std=c++23`:
```
In file included from <source>:1:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/memory:80:
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/unique_ptr.h:90:16: error: invalid application of 'sizeof' to an incomplete type 'C::Impl'
   90 |         static_assert(sizeof(_Tp)>0,
      | ^~~~~~~~~~~
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/bits/unique_ptr.h:398:4: note: in instantiation of member function 'std::default_delete<C::Impl>::operator()' requested here
  398 | get_deleter()(std::move(__ptr));
      |           ^
<source>:14:4: note: in instantiation of member function 'std::unique_ptr<C::Impl>::~unique_ptr' requested here
   14 | C::C() = default;
      |    ^
<source>:14:10: note: in defaulted default constructor for 'C' first required here
   14 | C::C() = default;
      |          ^
<source>:10:12: note: forward declaration of 'C::Impl'
   10 |     struct Impl;
      | ^
```

It builds fine with all previous standards as well as GCC and MSVC using C++23.

https://godbolt.org/z/9rx9j3KhP
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to