[llvm-bugs] [Bug 26787] [ms][EH] Clang cannot find appropriate catch statement for a throw

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 1 09:28:17 PST 2016


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

David Majnemer <david.majnemer at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |david.majnemer at gmail.com
         Resolution|---                         |INVALID

--- Comment #2 from David Majnemer <david.majnemer at gmail.com> ---
This is not a bug.

Clang uses C++11 rules when targeting compatibility with MSVC 2013.  MSVC 2013
is buggy and does not follow all the rules.  You will get the same behavior for
clang on linux if you supply -std=c++11.

Furthermore, MSVC 2015 has identical behavior to clang:
D:\>type t.cpp
#include <stdio.h>
struct A {
    ~A () { throw 1; }
};
struct B : public A {
    ~B()
    try { printf("B destructed\n"); }
    catch(int j) { printf("Caught %d in ~B\n", j); }
};
int main()
{
    try { B b; }
    catch (int j) {}
    return 0;
}
D:\>cl -w -O2 -EHs t.cpp && t
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23725 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

t.cpp
Microsoft (R) Incremental Linker Version 14.00.23725.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:t.exe
t.obj

$ ./t.exe
B destructed
$ echo $?
3

-- 
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/20160301/da9760a3/attachment.html>


More information about the llvm-bugs mailing list