[odb-users] Virtual std::vector< odb::lazy_shared_ptr<X> > crashes odb compiler

Boris Kolpackov boris at codesynthesis.com
Wed Mar 30 09:48:21 EDT 2016


Hi Dieter,

Thanks for the test case. This is a pretty hairy problem that has to do
with lazy template instantiation in C++. In essence, since your lazy_ptr
is not used anywhere else except as an element in a container in a
virtual data member, it doesn't get instantiated.

There is not much we can do to handle this automagically (instantiating
things on the fly is possible but would require incremental re-parsing of
the instantiated classes into the ODB's semantics graph). Though crashing
is also not right. So I've fixed it to issue proper diagnostics. Now for
your test case ODB prints:

test.h:51:16: error: container element type is not instantiated
test.h:51:16: info: use typedef/using to instantiate

As suggested in the diagnostics, the workaround is to force the (shallow)
instantiation with a typedef, for example:

typedef odb::lazy_shared_ptr<Employee> EmployeeLazyPtr;

Boris



More information about the odb-users mailing list