Why does -fsanitize=undefined cause "undefined reference to typeinfo"?
The answer to the actual question as asked is that -fsanitize=undefined
is actually a collection of sanitizers including the vptr
sanitizer.
https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
The vptr
sanitizer is clearly marked as requiring RTTI, which other answers have described why it's not available.
To run all the tests except vptr, you can say
-fsanitize=undefined -fno-sanitize=vptr
I think the -fsanitize=undefined
is a red herring.
You are only exporting the member functions of that class. In order to also export its metadata (like its typeinfo and potential v-table pointer) you need to export the class.
Try this
class EXPORT MyObject : public QObject
{
public:
MyObject (QObject * parent = nullptr);
~MyObject ();
void myMethod ();
};
Then you should not need to mark up the individual member functions.