https://bugs.llvm.org/show_bug.cgi?id=45876
Bug ID: 45876
Summary: wasm: __cxa_atexit called with wrong signature
function for global reference temporaries
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Backend: WebAssembly
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
The following snippet (from Dan Gohman):
struct B { B(); ~B(); };
namespace test {
const B b1 = B();
const B &b2 = B();
}
shows the problem -- the global_var_init that's generated to initialize the b2
reference is created with a call to __cxa_atexit that directly passes the
destructor. A dtor's function signature doesn't match what __cxa_atexit needs,
so there's a signature mismatch at execution time (at app exit).
For normal global destructors, there's a path that explicitly checks for
whether cxa_atexit can be called directly with a destructor, and if not,
generates a helper:
https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGDeclCXX.cpp#L106
But the reference temporary destructor goes through here (I think), which
doesn't check if the platform allows destructors to be passed to cxa_atexit:
https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGExpr.cpp#L347
Long-form discussion here:
https://bytecodealliance.zulipchat.com/#narrow/stream/206238-general/topic/__funcs_on_exit.20indirect.20call.20type.20mismatch.20with.20wasi-sdk
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs