disabling RTTI

S

shishir

Please consider the following

//file test.cpp
#include <iostream>
int main()
{
int x;
try
{
throw x;
}
catch(int x)
{
cout << "Caught\n ";
}
}
This program works fine when compiled with
g++ test.cpp
but when compile with
g++ -fno-rtti test.cpp, it crashes .

What could be the reason ? Is it that one can't one disable the rtti
option in isolation, i.e. fexception too has to be disabled ?
 
R

Risto Lankinen

shishir said:
Please consider the following

[C++ example using exceptions deleted]
This program works fine when compiled with
g++ test.cpp
but when compile with
g++ -fno-rtti test.cpp, it crashes .

What could be the reason ? Is it that one can't one disable the rtti
option in isolation, i.e. fexception too has to be disabled ?

One way to implement exceptions is to use the type_info
records that the RTTI infrastructure requires. This is not
the only way to implement exceptions, but it apparently is
being used in your compiler.

See http://tinyurl.com/33rlt for more...

Cheers!

- Risto -
 
R

Rolf Magnus

shishir said:
Please consider the following

//file test.cpp
#include <iostream>
int main()
{
int x;
try
{
throw x;
}
catch(int x)
{
cout << "Caught\n ";
}
}
This program works fine when compiled with
g++ test.cpp

It shouldn't. You're probably using a rather old and outdated version of
g++.
but when compile with
g++ -fno-rtti test.cpp, it crashes .

It doens't here (GCC 3.3.3).
What could be the reason ? Is it that one can't one disable the rtti
option in isolation, i.e. fexception too has to be disabled ?

I don't know what older g++ versions need. You might want to have a look
into the manual.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top