[PATCH] D32838: [libcxx] Make __shared_weak_count VTable consistent across all build configurations
Eric Fiselier via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 3 17:54:06 PDT 2017
EricWF added inline comments.
================
Comment at: src/memory.cpp:126-130
const void*
__shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
{
- return 0;
+ return nullptr;
}
----------------
dexonsmith wrote:
> If this is the right change, seems like the 0/nullptr change can be a separate NFC pre-commit.
>
> However, I wonder if this should call std::terminate or abort or something.
> - Previously, if someone with RTTI accidentally linked against such a library, they'd get a link error in this case.
> - Now, what happens?
> Now, what happens?
That's a good question without an easy answer.
> Previously, if someone with RTTI accidentally linked against such a library, they'd get a link error in this case.
Yep, that is true.
However if someone compiles a program with `-fno-rtti -D_LIBCPP_BUILD_STATIC` and links it to a library built w/ RTTI they will run into runtime errors and incorrect codegen since the vtable layout has silently changed. This is the problem I'm trying to fix.
> Now, what happens?
After this change it still fails to link when the library is built w/o RTTI but the program is. This is caused by the missing typeinfo definition for `__shared_weak_count`.
> I wonder if this should call std::terminate or abort or something.
This should never actually get called when programs are built with `-fno-rtti` because all of the call sites should be `#ifndef _LIBCPP_NO_RTTI` away, so there is no reason to abort or terminate.
https://reviews.llvm.org/D32838
More information about the cfe-commits
mailing list