[llvm-bugs] [Bug 51758] New: Destructor of std::any should not propagate exceptions

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Sep 5 12:45:40 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51758

            Bug ID: 51758
           Summary: Destructor of std::any should not propagate exceptions
           Product: libc++
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: johelegp at gmail.com
                CC: johelegp at gmail.com, llvm-bugs at lists.llvm.org,
                    mclow.lists at gmail.com

See https://godbolt.org/z/Yrszd3d4f, and
https://github.com/cplusplus/draft/issues/4863#issuecomment-913215699. The
destructor fails to meet the requirements of
https://eel.is/c++draft/res.on.exception.handling#3:
> Destructor operations defined in the C++ standard library shall not throw exceptions. Every destructor in the C++ standard library shall behave as if it had a non-throwing exception specification.
```C++
#include <any>
struct X { ~X() noexcept(false) { throw 0; } };
int main()
try {
  std::any x{X{}};
}
catch(int) {
  throw 0ull; // Terminate on thrown int means throw within noexcept
}
```
```
Program returned: 139
libc++abi: terminating with uncaught exception of type unsigned long long
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210905/5c823584/attachment.html>


More information about the llvm-bugs mailing list