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

            Bug ID: 120504
           Summary: [16 Regression] gcc-16 fails to build llvm-20 and
                    gdb-16.3 unique_ptr.h:91:23: error: invalid
                    application of 'sizeof' to incomplete type ... since
                    r16-944-g0629924777ea20
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
  Target Milestone: ---

Initially bisected against gdb-16.3 down to r16-944-g0629924777ea20 "c++: add
__is_*destructible builtins [PR107600]"

I'll steal Jonathan's https://gcc.gnu.org/PR107600#c6 example as is. Filing a
bug to make sure it does not get lost.

// $ cat a.cc

struct X;

template<class T>
struct default_delete
{
  void operator()(T*) { static_assert(sizeof(T), "type is not incomplete"); }
};

template<class T, class D = default_delete<T>>
struct unique_ptr
{
  ~unique_ptr() { del(ptr); }

  T* ptr;
  D del;
};


constexpr bool b = __has_trivial_destructor(unique_ptr<X>);


$ g++-15 -c a.cc
# ok

$ g++-16 -c a.cc
a.cc: In instantiation of 'void default_delete<T>::operator()(T*) [with T =
X]':
a.cc:12:22:   required from 'unique_ptr<T, D>::~unique_ptr() [with T = X; D =
default_delete<X>]'
   12 |   ~unique_ptr() { del(ptr); }
      |                   ~~~^~~~~
a.cc:19:58:   required from here
   19 | constexpr bool b = __has_trivial_destructor(unique_ptr<X>);
      |                                                          ^
a.cc:6:39: error: invalid application of 'sizeof' to incomplete type 'X'
    6 |   void operator()(T*) { static_assert(sizeof(T), "type is not
incomplete"); }
      |                                       ^~~~~~~~~

Reply via email to