Hello, I am having problems linking some test programs using std::expected. I am using LLVM 19.1.4 on macOS (homebrew) and when I link my library to some test code that does not explicitly use std::expected I get the following link errors.
Undefined symbols for architecture arm64:
"std::__1::bad_expected_access<void>::what() const", referenced from:
vtable for std::__1::bad_expected_access<dz::ErrorType> in tuple.test.cc.o
"typeinfo for std::__1::bad_expected_access<void>", referenced from:
typeinfo for std::__1::bad_expected_access<dz::ErrorType> in libdz.a[5](tuple.cc.o)
"vtable for std::__1::bad_expected_access<void>", referenced from:
std::__1::bad_expected_access<void>::bad_expected_access[abi:ne190104]() in tuple.test.cc.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
Even when I declare a dummy variable std::bad_expected_access<dz::ErrorType> x{dz::ErrorType::None};
I get the same errors.
Do I need to declare something for the program to link or for std::bad_expected_access<void>
to generate its vtable? std::bad_expected_access<void>
has a protected constructor, can’t directly instantiate it.