[Bug c++/85155] Suboptimal error messages when using noexcept(false) on defaulted dtor

2021-04-27 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85155

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |10.0

--- Comment #3 from Jonathan Wakely  ---
GCC accepts this code since this change in GCC 10:

Implement P1286R2, Contra CWG1778

The C++11 requirement that an explicit exception-specification on a
defaulted function match the implicit one was found to be problematic for
std::atomic.  This paper, adopted in February, simply removes that
requirement: if an explicitly defaulted function has a different
exception-specification, that now works just like a user-written function:
either it isn't noexcept when it could be, or it is noexcept and will call
terminate if an exception is thrown.

* method.c (defaulted_late_check): Don't check explicit
exception-specification on defaulted function.
(after_nsdmi_defaulted_late_checks): Remove.
* parser.h (struct cp_unparsed_functions_entry): Remove classes.
* parser.c (unparsed_classes): Remove.
(push_unparsed_function_queues, cp_parser_class_specifier_1):
Adjust.

From-SVN: r277351

[Bug c++/85155] Suboptimal error messages when using noexcept(false) on defaulted dtor

2018-07-03 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85155

--- Comment #2 from Jonathan Wakely  ---
GCC's behaviour is correct by the resolution of https://wg21.link/cwg1778 but
apparently that rule causes problems. Maybe Clang doesn't support it yet.

[Bug c++/85155] Suboptimal error messages when using noexcept(false) on defaulted dtor

2018-07-03 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85155

Jonathan Wakely  changed:

   What|Removed |Added

Version|8.0.1   |8.1.0

--- Comment #1 from Jonathan Wakely  ---
struct B {
  virtual ~B() noexcept(false) = default;
};

struct D : B {
  virtual ~D() { throw 17; }
};

int main()
{
  try {
D d;
return 1;
  } catch (int n) {
return n;
  }
}

EDG gives a similar result to GCC:


"85155.cc", line 6: error: nondeleted function overrides deleted function
  "B::~B"
virtual ~D() { throw 17; }
^

"85155.cc", line 6: error: function "B::~B()" (declared at line 2) cannot be
  referenced -- it is a deleted function
virtual ~D() { throw 17; }
^

"85155.cc", line 12: error: the default constructor of "D" cannot be referenced
  -- it is a deleted function
  D d;
^

3 errors detected in the compilation of "85155.cc".


Clang gives an error as soon as it sees the defaulted destructor, that's why
there are no errors given for the derived class:

struct B {
  virtual ~B() noexcept(false) = default;
};

85155.cc:2:11: error: exception specification of explicitly defaulted
destructor does not match the calculated one
  virtual ~B() noexcept(false) = default;
  ^
1 error generated.


I can't find any justification in the standard for Clang's behaviour, the
destructor should only be ill-formed if it is potentially invoked.