I had asked a question Do C++ POD types have RTTI? and someone told me in the comments:
POD types do have type_info, but don't have RTTI, and that's possible because type_info isn't always RTTI.
and it seems right as i could get the type_info
of a POD (non-polymorphic) type.
But while I compile this simple program:
#include <iostream>
struct X
{
int a;
};
int main()
{
using namespace std;
std::cout << typeid(X) << std::endl;
return 0;
}
with flag -fno-rtti
of GCC:
$ g++ -fno-rtti main.cpp && ./main
It won't compile:
main.cpp: In function ‘int main()’:
main.cpp:12:26: error: cannot use typeid with -fno-rtti
std::cout << typeid(X) << std::endl;
^
Does that mean type_info
is a part of RTTI, or is it just a behavior of GCC?