By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,820 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,820 IT Pros & Developers. It's quick & easy.

disabling RTTI

P: n/a
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 ?
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"shishir" <sh*******@indiatimes.com> wrote in message
news:a0**************************@posting.google.c om...
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 -
Jul 22 '05 #2

P: n/a
shishir wrote:
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.
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.