[cfe-dev] MSVC RTTI implementation status
David Chisnall
David.Chisnall at cl.cam.ac.uk
Tue Feb 25 00:56:41 PST 2014
On 25 Feb 2014, at 07:53, Domagoj Saric <domagoj.saric at littleendian.com> wrote:
> The problem basically appears if you have a polymorphic type in a TU compiled with -fno-rtti and you pass a pointer to such an object to a function in a TU compiled with -frtti which calls dynamic_cast on it...
I noticed yesterday that we don't warn on use of dynamic_cast compiling with -fno-rtti. While it can work if you are dynamic_casting a class from another compilation unit that is compiled with RTTI, there's a good chance that you're compiling most of your code with the same RTTI settings, so having a warning would be nice - users can always turn it off if they're sure that what they're doing is safe.
It would be really nice if you could turn RTTI generation on and off on specific classes (and have the setting propagated to inherited classes). I'm working on some code where subclasses of exactly one class want to do dynamic_cast, and rather than implementing an ad-hoc RTTI-like mechanism, it would be great to just set an attribute saying '[indirect] subclasses of this class must have RTTI generated, even if the global setting is not'.
David
More information about the cfe-dev
mailing list