<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang incorrectly generates noexcept assignment operator"
   href="https://bugs.llvm.org/show_bug.cgi?id=40896">40896</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang incorrectly generates noexcept assignment operator
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>alexey.kutumov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21525" name="attach_21525" title="Program which reproduces problem">attachment 21525</a> <a href="attachment.cgi?id=21525&action=edit" title="Program which reproduces problem">[details]</a></span>
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:
<a href="https://developercommunity.visualstudio.com/content/problem/456988/program-crashes-while-throwing-exception-inside-ge.html?childToView=470086#comment-470086">https://developercommunity.visualstudio.com/content/problem/456988/program-crashes-while-throwing-exception-inside-ge.html?childToView=470086#comment-470086</a>

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

<a href="http://eel.is/c++draft/except.spec#9">http://eel.is/c++draft/except.spec#9</a>

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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>