-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The combination of -fno-rtti -fexceptions is very brittle #66117
Comments
Thanks for summarizing. The proposed |
@llvm/issue-subscribers-c-1
The combination of `-fno-rtti` and `-fexceptions` is not supported very well, and we've seen several issues related to that internally at Apple. This bug report captures an analysis of this issue I did years ago to try to make it visible to the larger community.
Current behaviourWhen both these options are specified, we don't generate RTTI for types, except when a type is thrown, at which point we generate some minimal RTTI in the TU where it is thrown (I am not sure whether the "minimal RTTI is exactly the same as "normal RTTI"). Also note that we don't generate RTTI even in the place where a key function exists, and similarly we don't assume that other TUs have a definition of the RTTI when a key function exists. Problem with the current approachLet's say some TU Here's a minimal working example:
To map this example to reality, imagine that I once discussed this issue with @dexonsmith and we had discussed this potential solution:
rdar://58055046 |
The combination of
-fno-rtti
and-fexceptions
is not supported very well, and we've seen several issues related to that internally at Apple. This bug report captures an analysis of this issue I did years ago to try to make it visible to the larger community.Current behaviour
When both these options are specified, we don't generate RTTI for types, except when a type is thrown, at which point we generate some minimal RTTI in the TU where it is thrown (I am not sure whether the "minimal RTTI is exactly the same as "normal RTTI"). Also note that we don't generate RTTI even in the place where a key function exists, and similarly we don't assume that other TUs have a definition of the RTTI when a key function exists.
Problem with the current approach
Let's say some TU
a.cpp
built with-fno-rtti -fexceptions
calls a function (defined in some other TU) that can throw a typeE
, and tries to catchE
. Then, let's say that function is defined in some other TUb.cpp
built with-frtti -fexceptions
throws a typeE
. Let's also assume that another TUc.cpp
built with-frtti -fexceptions
defines the RTTI for E (through a key function, for example). The problem here is that ina.cpp
, we'll generate minimal RTTI for E, and inb.cpp
we'll use the normal RTTI assumed to be inc.cpp
(because there's a key function). Since the two RTTIs don't get de-duplicated, we get a type identity mismatch ina.cpp
andb.cpp
, and the exception isn't caught.Here's a minimal working example:
To map this example to reality, imagine that
E
is something likestd::exception
(or a derived class), thatb.dylib
islibc++.dylib
, and thata.exe
is a user program built with-fno-rtti -fexceptions
. It becomes clear why people are having problems with the feature.I once discussed this issue with @dexonsmith and we had discussed this potential solution:
-fno-rtti -fexceptions
, you get:rdar://58055046
The text was updated successfully, but these errors were encountered: