<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 - Implementing COM interfaces in MinGW broken by "Add Attribute NoThrow as an Exception Specifier Type""
   href="https://bugs.llvm.org/show_bug.cgi?id=42100">42100</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Implementing COM interfaces in MinGW broken by "Add Attribute NoThrow as an Exception Specifier Type"
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

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

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>martin@martin.st
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>erich.keane@intel.com, htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk, rnk@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The recent change "Add Attribute NoThrow as an Exception Specifier Type"
(<a href="https://reviews.llvm.org/D62435">https://reviews.llvm.org/D62435</a>, SVN r362119) broke code implementing COM
interfaces for the MinGW target.

Such code often ends up looking like this:

    class Base { 
    public:
        virtual __declspec(nothrow) void foo() = 0;
    };
    class Sub : public Base {
    public:
        void foo() { }
    };

Before this change, this never even warned (and doesn't warn with GCC either,
nor with MSVC). After this change, this is suddenly a hard error without a way
to disable the error.

One could of course fix the code to add the same attribute at the
implementation of the interface as well, but this seems to be the common
pattern of how one implements a COM interface, so I would expect there to be a
lot of code out there looking exactly like this.

By adding -fms-extensions, it is turned into a warning instead of an error
though, thanks to the following bit in lib/Sema/SemaExceptionSpec.cpp in
Sema::CheckOverridingFunctionExceptionSpec:

  unsigned DiagID = diag::err_override_exception_spec;
  if (getLangOpts().MicrosoftExt)
    DiagID = diag::ext_override_exception_spec;


Now for the MinGW case, the ideal would be to only degrade this to a warning
for cases with `__declspec(nothrow)`, not for the proper C++11 noexcept
specifier.


Do you (Reid and Erich) have any opinions on this? Is it better to change "Add
Attribute NoThrow as an Exception Specifier Type" to not do it for the MinGW
case at all (which would match GCC), or to degrade all exception spec
mismatches to warnings for this target?</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>