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

            Bug ID: 42217
           Summary: Bad exception handling with g++/MinGW
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Windows XP
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: COFF
          Assignee: unassignedb...@nondot.org
          Reporter: org...@gmail.com
                CC: llvm-bugs@lists.llvm.org

When building with g++ and lld, an exception that is thrown from a ctor is not
properly caught.

This works fine on linux with both g++ and clang, and on MinGW with clang.

$ cat ex.cpp
#include <iostream>

struct exception {};

struct Foo { Foo() { throw exception(); } };
static void func() { throw exception(); }

int main()
{
    try {
        func();
    } catch(exception &ex) { std::cout << "Caught from func" << std::endl; }
    try {
        Foo tmp;
    } catch(exception &ex) { std::cout << "Caught from ctor" << std::endl; }
    return 0;
}

$ clang++ -fuse-ld=lld -o ex.exe main.cpp

$ ./ex
Caught from func
Caught from ctor

$ g++ -fuse-ld=lld -o ex.exe main.cpp

$ ./ex
Caught from func
terminate called after throwing an instance of 'exception'

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to