[llvm-bugs] [Bug 33235] clang-cl doesn't treat __declspec(nothrow) as noexcept; fails to compile

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 15 13:52:52 PST 2019


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

Reid Kleckner <rnk at google.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |---
             Status|RESOLVED                    |REOPENED
                 CC|                            |rnk at google.com

--- Comment #5 from Reid Kleckner <rnk at google.com> ---
I think we need to do more work here. Clang warns on this code, and rejects it
outright in C++17, when MSVC accepts:

__declspec(nothrow) void __fastcall bar();
static_assert(noexcept(bar()));
__declspec(nothrow) void __fastcall bar() noexcept;
void foo() { bar(); }

$ clang-cl -std:c++17 -c t.cpp
t.cpp(3,37):  warning: exception specification in declaration does not match
previous declaration [-Wmicrosoft-exception-spec]
__declspec(nothrow) void __fastcall bar() noexcept;
                                    ^
t.cpp(1,37):  note: previous declaration is here
__declspec(nothrow) void __fastcall bar();
                                    ^
t.cpp(3,37):  error: conflicting types for 'bar'
__declspec(nothrow) void __fastcall bar() noexcept;
                                    ^
t.cpp(1,37):  note: previous declaration is here
__declspec(nothrow) void __fastcall bar();
                                    ^
1 warning and 1 error generated.

If you remove the -std:c++17, the "conflicting types" error goes away.

It's confusing that 'noexcept(bar())' evaluates to 'true' when
__declspec(nothrow) is present, but then we complain about mismatched types and
EH specifiers.

-- 
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/20190115/679071c6/attachment.html>


More information about the llvm-bugs mailing list