[llvm-bugs] [Bug 42217] New: Bad exception handling with g++/MinGW

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 10 05:59:37 PDT 2019


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: unassignedbugs at nondot.org
          Reporter: orgads at gmail.com
                CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190610/3df41edc/attachment.html>


More information about the llvm-bugs mailing list