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

            Bug ID: 95860
           Summary: Wrong "looser exception specification" when a class
                    has 2 prospective destructors.
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: okannen at gmail dot com
  Target Milestone: ---

Tested with gcc --version:
gcc (GCC) 10.1.1 20200613
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The following code should compile:

struct A {
        virtual ~A() =default;
        };

template <bool C>
struct B 
        :A
        {
        ~ B() =default;                 //destructor 1
        ~ B() requires (C) =default;    //destructor 2

        };

int main(){
        B<true> b;
        }
The destructor of B<true> is the "destrurcor 2". Nevertheless, GCC complains
that "destructor 1" has a looser exception specification than the base
destructor:

test.cpp: In instantiation of ‘struct B<true>’:
test.cpp:144:10:   required from here
test.cpp:138:2: error: looser exception specification on overriding virtual
function ‘B<C>::~B() [with bool C = true]’
  138 |  ~ B() =default;
      |  ^
test.cpp:131:10: note: overridden function is ‘virtual constexpr A::~A()
noexcept’
  131 |  virtual ~A() =default;
      |          ^

Reply via email to