[cfe-dev] typeid and fno-rtti
rjmccall at apple.com
Fri May 18 11:59:20 PDT 2012
On May 18, 2012, at 6:30 AM, Michel Morin wrote:
> I compiled the following code on clang (trunk) + libc++
> with -fno-rtti compiler option:
> #include <typeinfo>
> int main (int argc, char* argv)
> bool x = (typeid(int) == typeid(int)); // Segmentation fault
> return 0;
> Then, I got segmentation fault at `bool x = (typeid(int) == typeid(int));`.
> So I checked `&typeid(int)`, and it turned out to be a null pointer.
> I suspect that, with -fno-rtti compiler option, `typeid(int)` becomes
> something like `*static_cast<type_info*>(0)`.
> If so, shouldn't we disable `typeid` operator when -fno-rtti is specified?
> The current behavior of `typeid` with -fno-rtti option is useless.
> (c.f. On gcc, the use of `typeid` requires RTTI.)
I agree that -fno-rtti should disable typeid. Please file a bug:
Also, patches welcome.
More information about the cfe-dev