typeid and fno-rtti

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.)

Regards,
Michel

I agree that -fno-rtti should disable typeid. Please file a bug:
  http://llvm.org/bugs/
Also, patches welcome.

John.

John McCall wrote:

I agree that -fno-rtti should disable typeid. Please file a bug:
http://llvm.org/bugs/

Done.
  http://llvm.org/bugs/show_bug.cgi?id=12888

Also, patches welcome.

I don't have enough knowledge about clang implementation to contribute...
But I just applied the corresponding fix to Boost.Config :slight_smile:
  https://svn.boost.org/trac/boost/changeset/78510

Regards,
Michel