https://bugs.llvm.org/show_bug.cgi?id=40896
Bug ID: 40896
Summary: clang incorrectly generates noexcept assignment
operator
Product: clang
Version: 7.0
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
Created attachment 21525
--> https://bugs.llvm.org/attachment.cgi?id=21525&action=edit
Program which reproduces problem
Consider following example (bad.cpp in atttachment). In this example i have
struct VectorWrapper with following assignment operator:
VectorWrapper& operator=(VectorWrapper) noexcept {
return *this;
}
Which is really noexcept
And copy ctor:
VectorWrapper(const VectorWrapper& ){
throw 42;
}
Which is *not* noexcept
If i wrap this struct into
struct MyData {
VectorWrapper vec;
};
And tries to copy one instance of MyData into another my program crashes even
if i try to catch exception (as seen in bad.cpp).
I suppose that compiler marks assignment operator of MyData as *noexcept* while
it actually is *NOT* noexcept, because it calls copy ctor of VectorWrapper.
I've filed same bug to MSVC:
https://developercommunity.visualstudio.com/content/problem/456988/program-crashes-while-throwing-exception-inside-ge.html?childToView=470086#comment-470086
They said that there is a bug in implementation:
For reference, here's what the Standard has to say:
The exception specification for an implicitly-declared assignment operator, or
an assignment-operator without a noexcept-specifier that is defaulted on its
first declaration, is potentially-throwing if and only if the invocation of any
assignment operator in the implicit definition is potentially-throwing
http://eel.is/c++draft/except.spec#9
Our interpretation of "invocation of any assignment operator" includes the
argument conversions required, not just the specific function(s) being called.
This wording changed quite a bit since C++14, where it explicitly called out
"any function it directly invokes" which would more obviously include the copy
constructor call, yet still no compiler I tried implemented this.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs