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

typeid behavior on object without RTTI

P: n/a
What happens if I invoke typeid on an object that's
part of a library that was compiled w/o RTTI enabled?

Is this undefined behavior? If not, is a bad_typeid
exception what I should expect? That's what my
implementation does, but I'm not sure if this behavior
conforms to the standard.

Thanks.
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Derek wrote:
What happens if I invoke typeid on an object that's
part of a library that was compiled w/o RTTI enabled?

Is this undefined behavior? If not, is a bad_typeid
exception what I should expect? That's what my
implementation does, but I'm not sure if this behavior
conforms to the standard.


The standard requires RTTI.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 23 '05 #2

P: n/a
Derek wrote:
What happens if I invoke typeid on an object that's
part of a library that was compiled w/o RTTI enabled?

Is this undefined behavior? If not, is a bad_typeid
exception what I should expect? That's what my
implementation does, but I'm not sure if this behavior
conforms to the standard.


In Standard C++, RTTI cannot be disabled. So there is no behavior that
conforms to the standard. It's not just undefined, it's even not Standard
C++ at all.

Jul 23 '05 #3

P: n/a
"Derek" <us**@nospam.org> wrote in message
news:3a*************@individual.net...
What happens if I invoke typeid on an object that's
part of a library that was compiled w/o RTTI enabled?

Is this undefined behavior? If not, is a bad_typeid
exception what I should expect? That's what my
implementation does, but I'm not sure if this behavior
conforms to the standard.


I think, "Try it and find out," is appropriate here. The other two posts are
true, but another answer that is surely no less true is, "God only knows," which
is I think more along the lines of the practical answer you seem to be looking
for.

- JFA1
Jul 23 '05 #4

P: n/a
> What happens if I invoke typeid on an object that's
part of a library that was compiled w/o RTTI enabled?


"Disabling" RTTI is against the standard, so whatever happens after is
undefined behaviour.

cheers,
Marcin

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.