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

            Bug ID: 128243
           Summary: GCC incorrectly reject explicit qualified destructor
                    calls inside class templates with an "invalid use of
                    incomplete type" error.
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aposhtarenko at proton dot me
  Target Milestone: ---

Created attachment 66005
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=66005&action=edit
gcc -v -save-temps s.cpp

Code:

template<typename T>
class C{
public:
    virtual ~C(){
    }
    void destroy(){
        C::~C();
    }
};

GCC produces error: invalid use of incomplete type ‘class C<T>’ on C::~C()
statement. this->C::~C() or this->~C() works without errors. Clang/MSVC/EDG
have no issues with that code (https://godbolt.org/z/hWbnbzdar). Adding
variable declaration "C c" doesn't produce any errors, so in the same context
class C is complete and incomplete according to GCC:


template<typename T>
class C{
public:
    virtual ~C(){
    }
    void destroy(){
        C c;      // C is complete here
        C::~C();  // C is incomplete here?
    }
};

gcc 7.5 can compile that code, but 8.1 can't.

Reply via email to