[LLVMbugs] [Bug 22423] New: Strong enums not shareable between C++ / ObjC++
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jan 30 19:57:57 PST 2015
http://llvm.org/bugs/show_bug.cgi?id=22423
Bug ID: 22423
Summary: Strong enums not shareable between C++ / ObjC++
Product: libc++
Version: unspecified
Hardware: Other
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: pgriess at gmail.com
CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
Classification: Unclassified
In __config, we have the following
#if !(__has_feature(cxx_strong_enums))
#define _LIBCPP_HAS_NO_STRONG_ENUMS
#endif
...
#if __has_feature(objc_arc_weak)
#define _LIBCPP_HAS_OBJC_ARC_WEAK
#define _LIBCPP_HAS_NO_STRONG_ENUMS
#endif
As a result, C++ code will have strong enums enabled, while ObjC++ code will
not. This causes problems with classes like std::cv_status which are used as
return values, as they become composite types. The ARM calling conventions
(see:
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf
section 5.4) mandates different calling conventions for such return types. As a
result, if caller and callee have different values for
_LIBCPP_HAS_NO_STRONG_ENUMS, registers are allocated differently (e.g. r0 is
used to specify the address of the return value in one, where as r0 is the
value of 'this' in the other).
Practically, this occurs when instantiating templates in different compilation
units, as the definitions are different, but are coalesced in linking due to
ODR. Linking the two files into a single binary will result in a crash:
Foo.cpp
void foo() {
std::mutex m;
std::unique_lock<std::mutex> lk(m);
std::condition_variable cv;
std::chrono::seconds dur(3);
cv.wait_for(lk, dur);
}
Bar.mm:
void bar() {
std::mutex m;
std::unique_lock<std::mutex> lk(m);
std::condition_variable cv;
std::chrono::seconds dur(3);
cv.wait_for(lk, dur);
}
main.c:
foo();
bar();
Application developers can work around this by building mixed C++/ObjC++ apps
with _LIBCPP_HAS_NO_STRONG_ENUMS=1.
--
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/20150131/9611b326/attachment.html>
More information about the llvm-bugs
mailing list