[llvm-bugs] [Bug 49037] New: exception is not ABI-compatible with libstdc++

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Feb 4 09:01:27 PST 2021


            Bug ID: 49037
           Summary: exception is not ABI-compatible with libstdc++
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yichen.yan at inf.ethz.ch
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Created attachment 24482
  --> https://bugs.llvm.org/attachment.cgi?id=24482&action=edit
make run

If I'm not mistaken,

> ABI compatibility with gcc's libstdc++ for some low-level features such as exception objects...
means that we can use libraries compiled with libstdc++ with libc++ and the
exception works well.

I found the case that try-catch statement is not working as expected, which
seems due to some ABI issue.

root at 10155041665b:/test# make run
g++ -c lib.cc -fpic -o lib.o```
g++ -nostdinc++ -I/libcxx-install-11/include/c++/v1 -nodefaultlibs
-L/libcxx-install-11/lib -lc++ -lc++abi -lm -lc -lgcc_s -lgcc \
main.cc lib.o -o a.out
LD_LIBRARY_PATH=/libcxx-install-11/lib ./a.out
root at 10155041665b:/test# cat main.cc 
#include <iostream>

#include "lib.h"

int main() {
    try {
        throw gen();
    } catch (const e& exp) {
        std::cout << 1 << std::endl;
    } catch (...) {
        std::cout << 2 << std::endl;
root at 10155041665b:/test# cat lib.cc 
#include "lib.h"

std::runtime_error gen() {
    return e("");
root at 10155041665b:/test# cat lib.h 
#include <stdexcept>

struct e : public std::runtime_error {
    explicit e(const char* what) :
        std::runtime_error(what) {

std::runtime_error gen();

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/20210204/2b205384/attachment.html>

More information about the llvm-bugs mailing list