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

            Bug ID: 90455
           Summary: braced-init and incomplete type instantiation
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: faithandbrave at gmail dot com
  Target Milestone: ---

Pattern A (OK) :

#include <memory>
struct B;
struct A { std::unique_ptr<B> p; };
int main() {}


Pattern B (Compilation Error) :

#include <memory>
struct B;
struct A { std::unique_ptr<B> p{}; };
int main() {}

===error begin===
In file included from /opt/wandbox/gcc-9.1.0/include/c++/9.1.0/memory:80,
                 from prog.cc:1:
/opt/wandbox/gcc-9.1.0/include/c++/9.1.0/bits/unique_ptr.h: In instantiation of
'void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = B]':
/opt/wandbox/gcc-9.1.0/include/c++/9.1.0/bits/unique_ptr.h:289:17:   required
from 'std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = B; _Dp =
std::default_delete<B>]'
prog.cc:4:33:   required from here
/opt/wandbox/gcc-9.1.0/include/c++/9.1.0/bits/unique_ptr.h:79:16: error:
invalid application of 'sizeof' to incomplete type 'B'
   79 |  static_assert(sizeof(_Tp)>0,
      |                ^~~~~~~~~~~
===error end===

Clang with libc++ is OK both.
default_delete implementation is libstdc++ and libc++ are same.

I think the issue is compiler issue.

Reply via email to